-
Notifications
You must be signed in to change notification settings - Fork 752
TypeOffset class no longer depends on target Python version #1292
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
TypeOffset class no longer depends on target Python version #1292
Conversation
tools/geninterop/geninterop.py
Outdated
@@ -351,6 +350,10 @@ def main(): | |||
gen_interop_head(writer) | |||
|
|||
gen_heap_type_members(ast_parser, writer) | |||
|
|||
ver_define = "PYTHON{0}{1}".format(PY_MAJOR, PY_MINOR) | |||
writer.append(code="#if " + ver_define) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these still behind a compile-time flag? Do you plan to change that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I am approaching this gradually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked this out, and the rest of the conditional stuff came from 1b466df. Since it was only used to determine if methods in Python.Runtime itself implement slots (which we can do on our own), I took a liberty to mostly revert it in this PR. Reversal is in this commit
d6f4834
to
3bc282a
Compare
Codecov Report
@@ Coverage Diff @@
## master #1292 +/- ##
=======================================
Coverage 87.97% 87.97%
=======================================
Files 1 1
Lines 291 291
=======================================
Hits 256 256
Misses 35 35
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
Hm, Travis build on Linux with Python 3.9 regularly fails with this change. Could I have screwed up something here? @filmor, you've recently added support for 3.9. Was there anything specific to Linux? |
Nope, the only reason why support for 3.9 took so long was that I had to adjust the interop generation as it wasn't working with the new header-files anymore. |
@filmor , oh, nvm. Looks like Travis just used older commit for 3.9 o-O It passes now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine for now, just minor things that I think could be fixed.
3bc282a
to
a2c13c7
Compare
Instead, for each supported Python version a separate class is generated (e.g. TypeOffset36). Then the Runtime picks the correct class using reflection, and copies only the necessary TypeOffset members over from it. ManagedDataOffsets.Magic is now also read at runtime from tp_basicsize of PyType
a2c13c7
to
e36a027
Compare
This is a stage of removing the need to prepare a separate build of
Python.Runtime
for each Python version.What does this implement/fix? Explain your changes.
This removes the need to pick
TypeOffset
at compile time. Instead, for each supported Python version a separate class is generated (e.g.TypeOffset36
). Then theRuntime
(via new classABI
) picks the correct class based on actual Python version using reflection, and copies only the necessaryTypeOffset
members over from it.ManagedDataOffsets.Magic
is now also read at runtime fromtp_basicsize
of thebuiltins.type
class.Any other comments?
N/A
Checklist
Check all those that are applicable and complete. N/A
AUTHORS
CHANGELOG