Add Py_GenericAlias#45
Conversation
Useful for extensions implementing generic container types, like `immutables` (see MagicStack/immutables#89). Co-Authored-By: ToBeReplaced <ToBeReplaced@gmail.com>
vstinner
left a comment
There was a problem hiding this comment.
I'm not sure if this implementation fits well with pythoncapi-compat. Usually, I only provided a fallback implementation when they was a way to implement a feature on old Python. For example, PyFrame_GetBack(frame) really returns the previous frame. And PyThreadState_EnterTracing() and PyThreadState_LeaveTracing() really work as the function works on Python 3.11.
Here, it's not a type alias, it just returns the same input type, unmodified, and the second argument is just ignored. I don't see the value of adding this function to pythoncapi-compat. Why not puting an #ifdef in immutables to have a different code path on Python 3.8 and older?
In shorter, I prefer that the developer of a C extension thinks how they have to deal with Python 3.8 and older.
Sorry, I didn't put any guidelines on what belongs or not to pythoncapi-compat.
Yeah, that makes sense, thanks for confirming. Easy to handle in the extension directly. |
Useful for extensions implementing generic container types, like
immutables(see MagicStack/immutables#89).Co-Authored-By: ToBeReplaced ToBeReplaced@gmail.com