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

bpo-43908: Types with Py_TPFLAGS_IMMUTABLETYPE can now inherit the vectorcall protocol #27001

Merged
merged 15 commits into from
Jul 8, 2021

Conversation

erlend-aasland
Copy link
Contributor

@erlend-aasland erlend-aasland commented Jul 2, 2021

Py_TPFLAGS_HAVE_VECTORCALL and Py_TPFLAGS_METHOD_DESCRIPTOR
inheritance is now ruled by the Py_TPFLAGS_IMMUTABLETYPE flag instead
of the Py_TPFLAGS_HEAPTYPE flag.

https://bugs.python.org/issue43908

@erlend-aasland
Copy link
Contributor Author

cc. @pablogsal

@erlend-aasland erlend-aasland changed the title bpo-43908: Use Py_TPFLAGS_IMMUTABLETYPE to decide if vectorcall type flags can be inherited bpo-43908: Types with Py_TPFLAGS_IMMUTABLETYPE can now implement the vectorcall protocol Jul 2, 2021
@erlend-aasland erlend-aasland reopened this Jul 5, 2021
@erlend-aasland
Copy link
Contributor Author

Re-opening to trigger CI.

Copy link
Member

@pablogsal pablogsal left a comment

Choose a reason for hiding this comment

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

LGTM

It would be great if @vstinner could take a look as he has been dealing with this heavily recently. If he cannot review in a week or so, ping me again and I will merge :)

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM. But to be able to merge this change, please move the news entry to Doc/whatsnew/3.10.rst. I suggest to backport this nice enhancement to Python 3.10.

@erlend-aasland
Copy link
Contributor Author

LGTM. But to be able to merge this change, please move the news entry to Doc/whatsnew/3.10.rst. I suggest to backport this nice enhancement to Python 3.10.

Ok, moved to 3.10 in commit 6adc9e5. Thanks for reviewing, Pablo & Victor! 🙏🏻

@erlend-aasland erlend-aasland added the needs backport to 3.10 only security fixes label Jul 6, 2021
@pablogsal
Copy link
Member

LGTM. But to be able to merge this change, please move the news entry to Doc/whatsnew/3.10.rst. I suggest to backport this nice enhancement to Python 3.10.

Is this considered a bugfix? We are very close to RC 1 so I'm not sure we should risk regressions...

@erlend-aasland
Copy link
Contributor Author

Is this considered a bugfix?

I guess it depends on how you view it:

  1. <some-type> used to be a static type before 3.10; now it's a heap type, and has hence lost the option of adding vectorcall support => bug! :)
  2. immutable heap types can now implement the vectorcall protocol => (micro) feature! :)

@pablogsal
Copy link
Member

now it's a heap type

But this is something only happens in the stdlib, and those types are not going to change between beta 4 and RC 1. User types are not going to become magically heap types.

I'm missing something?

@erlend-aasland
Copy link
Contributor Author

erlend-aasland commented Jul 6, 2021

now it's a heap type

But this is something only happens in the stdlib, and those types are not going to change between beta 4 and RC 1. User types are not going to become magically heap types.

I'm missing something?

No, that's correct. If vectorcall support is not going to be added to any stdlib type in 3.10, there's no reason to backport this.

@erlend-aasland
Copy link
Contributor Author

erlend-aasland commented Jul 6, 2021

Sounds like a backport is out of the question, then.
I'll revert the last commit and remove the label.
I've reverted 6adc9e5 and removed the backport label.

@erlend-aasland erlend-aasland removed the needs backport to 3.10 only security fixes label Jul 6, 2021
@erlend-aasland erlend-aasland requested a review from pablogsal July 6, 2021 15:40
@vstinner
Copy link
Member

vstinner commented Jul 6, 2021

@pablogsal:

Is this considered a bugfix? We are very close to RC 1 so I'm not sure we should risk regressions...

Ah, I didn't notice that there are two months between the RC1 and the final versions. Ok, so this change should not be backported.

@erlend-aasland erlend-aasland changed the title bpo-43908: Types with Py_TPFLAGS_IMMUTABLETYPE can now implement the vectorcall protocol bpo-43908: Types with Py_TPFLAGS_IMMUTABLETYPE can now inherit the vectorcall protocol Jul 6, 2021
Erlend Egeberg Aasland and others added 2 commits July 7, 2021 20:54
@erlend-aasland erlend-aasland requested a review from vstinner July 7, 2021 18:57
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks, the NEWS entry is now crystal clear.

@@ -710,7 +710,7 @@ and :c:type:`PyType_Type` effectively act as defaults.)

.. warning::

It is not recommended for :ref:`heap types <heap-types>` to implement
It is not recommended for :ref:`mutable heap types <heap-types>` to implement
Copy link
Member

Choose a reason for hiding this comment

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

Note: It's non-obvious what "mutable" means. It would be nice to add (in a separated PR) a new "Immutable types" section near https://docs.python.org/dev/c-api/typeobj.html#heap-types to explain the effects of the Py_TPFLAGS_IMMUTABLETYPE flag and explains that static types get this flag automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. I'll see if I can find time for it. Thanks again for reviewing!

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

Successfully merging this pull request may close these issues.

5 participants