GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||
GeezerVison is showing github.com — bpo-40170: Add PyType_SetBase() function by vstinner · Pull Request #23153 · python/cpython Conversation
|
|
After Py_SET_TYPE(), here is a new function to abstract access to the PyTypeObject structure: PyType_SetBase() to set the tp_base member. PyType_SetBase() is safer than a direct access to tp_base since it handles reference count for the caller. PyType_SetBaseStatic() is also provided for compatibility with extension modules using static types: set tp_base member, but don't touch reference count. The PR also fix a reference leak in PyType_Ready():
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Nice improvement. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If Line 2995 can be replaced, why Line 842 can not do the same operation?
https://github.com/python/cpython/blob/master/Objects/typeobject.c#L842
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
type_set_bases() is very complex, I prefer to leave it unchanged to reduce the risk of any regression. IMHO the current type_set_bases() code is simpler to follow without an indirection like PyType_SetBase() function call.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
It would be possible, but I prefer one function per PyTypeObject member. For example, PyType_SetBase() cannot fail. A function which would accept a parameter to choose the slot would introduce error handling, to handle invalid/unknown slot. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
hello sir i accidently removed my reviewer and now it is saying awating core review but there are no one under reviewer section. can you plese help me it is not saying like yours |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Hello, Yash. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Add PyType_SetBase() and PyType_SetBaseStatic() functions to set the base of a type. PyType_Ready() no longer increment the reference count of the object type on static types which have no base type and use a borrowed reference to their base type.
|
I rebased my PR and fixed the typo spotted by @Jongy. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Wait, this PR doesn't make any sense. The purpose of bpo-40170 is to move the C API towards opaque PyTypeObject structure. This PR adds PyType_SetBase() for heap types and PyType_SetBaseStatic() for static types. PyType_SetBase() is only used in typeobject.c because it doesn't make sense to update tp_base after a type is created. So PyType_SetBase() is useless. PyType_SetBaseStatic() doesn't solve bpo-40170: defining a static types requires that the PyTypeObject structure is not opaque. It is not possible to define a type statically if PyTypeObject is opaque. So PyType_SetBaseStatic() is useless. This PR is useless, I close it. Moreover, PyType_FromSpecWithBases() can be used to create a heap type with a base type. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I saw a lot of code setting tp_base on types, but I didn't notice that all these types were statically defined. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.