Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-92123: Convert _elementtree types to heap types #99221

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

erlend-aasland
Copy link
Contributor

@erlend-aasland erlend-aasland commented Nov 7, 2022

@kumaraditya303
Copy link
Contributor

With #100689 the capsule also needs to isolated. LMK when this goes out of draft.

@erlend-aasland
Copy link
Contributor Author

With #100689 the capsule also needs to isolated. LMK when this goes out of draft.

Yes, I also made a note of that. I hope to be able to allocate time for CPython this weekend.

@erlend-aasland
Copy link
Contributor Author

erlend-aasland commented Jan 12, 2023

I remember doing a proof-of-concept full isolation of _elementtree some years ago, and the diff ended up close to 1000 lines. I suggest breaking this up in several PRs. Approximately something like this:

  1. since there's already a module state, we should start by getting rid of ET_STATE_GLOBAL (large diff)
  2. then, implement multi-phase init (small diff)
  3. then, we can pull those changes into this PR, and we should probaly be good to go

We might want to split the ET_STATE_GLOBAL-thing in multiple PRs. It's bound to end up ugly.

UDPATE

This plan won't work out, because we need heap types before being able to completely get rid of ET_STATE_GLOBAL. We also need to get rid of ET_STATE_GLOBAL in order to implement multi-phase init. Things are entwined. Alternative plan:

  1. land this PR
  2. move the heap types into state struct (short PR; easy to review)
  3. get rid of ET_STATE_GLOBAL (possibly multiple PRs; this part is messy)
  4. implement multi-phase init (short PR; easy to review)

@erlend-aasland erlend-aasland marked this pull request as ready for review Jan 18, 2023
@erlend-aasland
Copy link
Contributor Author

@kumaraditya303: I wonder if we should tie this PR to gh-92123, or if we should create a targeted issue specifically for isolating _elementtree.

@erlend-aasland erlend-aasland changed the title WIP: Isolate elementtree PEP 687: Convert _elementtree types to heap types Jan 18, 2023
@erlend-aasland erlend-aasland added the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Jan 18, 2023
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @erlend-aasland for commit 744be65 🤖

If you want to schedule another build, you need to add the :hammer: test-with-refleak-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Jan 18, 2023
@kumaraditya303
Copy link
Contributor

I wonder if we should tie this PR to #92123, or if we should create a targeted issue specifically for isolating _elementtree.

Let's link it to the bug report, we did a similar thing for asyncio IIRC.

I am in favor of landing this PR and continue other improvements in smaller PRs.

Modules/_elementtree.c Outdated Show resolved Hide resolved
Modules/_elementtree.c Outdated Show resolved Hide resolved
Modules/_elementtree.c Outdated Show resolved Hide resolved
Modules/_elementtree.c Outdated Show resolved Hide resolved
@erlend-aasland erlend-aasland changed the title PEP 687: Convert _elementtree types to heap types gh-92123: Convert _elementtree types to heap types Jan 19, 2023
@erlend-aasland
Copy link
Contributor Author

@kumaraditya303: thanks for the immutable types reminder; I also had forgotten to disallow instantiation for the iter type.

@erlend-aasland erlend-aasland added the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Jan 19, 2023
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @erlend-aasland for commit 04aaa3d 🤖

If you want to schedule another build, you need to add the :hammer: test-with-refleak-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Jan 19, 2023
}
} else {
return NULL;
goto error;
}

st->str_append = PyUnicode_InternFromString("append");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also change NULL checks like on line 4269 to goto error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that a result of a bad merge. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, the interned strings are not freed in the module clear/free functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants