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 — gh-94673: Clarify About Runtime State Related to Static Builtin Types by ericsnowcurrently · Pull Request #117761 · python/cpython Conversation
|
| Those objects are stored in the PyInterpreterState.types.builtins | ||
| array, at the index corresponding to each specific static builtin | ||
| type. That index (a size_t value) is stored in the tp_subclasses | ||
| field (defined as PyObject*). We re-purposed the now-unused |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actually, it's void *.
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.
fixed
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| { | ||
| if (!static_builtin_index_is_set(self)) { | ||
| static_builtin_index_set(self, interp->types.num_builtins_initialized); | ||
| assert(_Py_IsMainInterpreter(interp)); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
In static_builtin_state_clear() there's a check for this rather than an assert. Maybe it should be an if here too, for symmetry? (Maybe the assert should be !static_builtin_index_is_set()?)
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.
Good point. I'll flip it around.
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.
fixed
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (!static_builtin_index_is_set(self)) { | ||
| static_builtin_index_set(self, interp->types.num_builtins_initialized); | ||
| assert(_Py_IsMainInterpreter(interp)); | ||
| assert(interp->types.num_builtins_initialized == \ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It's C. :-)
| assert(interp->types.num_builtins_initialized == \ | |
| assert(interp->types.num_builtins_initialized == |
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.
dropped
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
| else { | ||
| assert(!_Py_IsMainInterpreter(interp)); | ||
| assert(static_builtin_index_get(self) == \ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| assert(static_builtin_index_get(self) == \ | |
| assert(static_builtin_index_get(self) == |
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.
fixed
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This reverts commit b8d622e.
Good point. I've dropped the extra counter. |
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.
Perfect!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… Types (pythongh-117761) Guido pointed out to me that some details about the per-interpreter state for the builtin types aren't especially clear. I'm addressing that by: * adding a comment explaining that state * adding some asserts to point out the relationship between each index and the interp/global runtime state
|
After this PR, |
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.