Skip to content

Conversation

@erlend-aasland
Copy link
Contributor

@erlend-aaslanderlend-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
ContributorAuthor

cc. @pablogsal

@erlend-aaslanderlend-aasland changed the title bpo-43908: Use Py_TPFLAGS_IMMUTABLETYPE to decide if vectorcall type flags can be inheritedbpo-43908: Types with Py_TPFLAGS_IMMUTABLETYPE can now implement the vectorcall protocolJul 2, 2021
@erlend-aasland
Copy link
ContributorAuthor

Re-opening to trigger CI.

Copy link
Member

@pablogsalpablogsal 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

@vstinnervstinner 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
ContributorAuthor

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-aaslanderlend-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
ContributorAuthor

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
ContributorAuthor

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
ContributorAuthor

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-aaslanderlend-aasland removed the needs backport to 3.10 only security fixes label Jul 6, 2021
@vstinner
Copy link
Member

@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-aaslanderlend-aasland changed the title bpo-43908: Types with Py_TPFLAGS_IMMUTABLETYPE can now implement the vectorcall protocolbpo-43908: Types with Py_TPFLAGS_IMMUTABLETYPE can now inherit the vectorcall protocolJul 6, 2021
Copy link
Member

@vstinnervstinner 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.

.. 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
ContributorAuthor

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 freeto 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

@erlend-aasland@pablogsal@vstinner@the-knights-who-say-ni@bedevere-bot