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-148871: extend and improve `LOAD_COMMON_CONSTANT` by NekoAsakura · Pull Request #148971 · python/cpython Conversation
|
| Change | main | branch | |
|---|---|---|---|
| 1 | all.__self__ / any.__self__ |
<module 'builtins'> |
None |
| 2 | gc.is_tracked(all) / gc.is_tracked(any) |
True |
False |
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.
Mostly looks good.
You need to take care distinguishing between process-wide data and per-interpreter data. See the comments below.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| meth_getsets, /* tp_getset */ | ||
| 0, /* tp_base */ | ||
| 0, /* tp_dict */ | ||
| 0, /* tp_descr_get */ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this list of zeros and use a named initializer: .tp_is_gc = cfunction_is_gc
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return PyLong_FromLong(oparg); | ||
| } | ||
| if (opcode == LOAD_COMMON_CONSTANT) { | ||
| switch (oparg) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| switch (oparg) { | |
| return load_common_const(oparg); |
All these objects are immortal, so no need to worry about reference counts
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| op(_LOAD_COMMON_CONSTANT, (-- value)) { | ||
| assert(oparg < NUM_COMMON_CONSTANTS); | ||
| PyObject *val = _PyInterpreterState_GET()->common_consts[oparg]; | ||
| PyObject *val; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why aren't you using the constants table?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| static inline _PyStackRef | ||
| load_common_constant(unsigned int oparg) | ||
| { | ||
| switch (oparg) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? These values should be in the table
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| .vectorcall = _PyCFunction_vectorcall_O, | ||
| }; | ||
|
|
||
| PyObject *_PyCommonConsts[NUM_COMMON_CONSTANTS]; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
For this to be process-wide (not per-interpreter) PyExc_AssertionError and PyExc_NotImplementedError will need to be statically allocated.
Doing that might be complex, so maybe keep the constants per-interpreter for this PR, and make everything statically allocation in a later PR?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| (PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS - 1]; | ||
| for (int i = 0; i < NUM_COMMON_CONSTANTS; i++) { | ||
| assert(_PyCommonConsts[i] != NULL); | ||
| assert(_Py_IsImmortal(_PyCommonConsts[i])); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| assert(_Py_IsImmortal(_PyCommonConsts[i])); | |
| assert(_Py_IsStaticImmortal(_PyCommonConsts[i])); |
If _PyCommonConsts is to be statically allocated.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase And if you don't make the requested changes, you will be poked with soft cushions! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for the review. Pushed the lot. :') |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This looks good, except the changes to Sorry to go and forth on this, but I think we shouldn't make I'm worried that the changes to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sound call. Reverted. Thanks again for the review. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Documentation build overview
61 files changed ·
|
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.
This fixes the compiler and selection of constants.
There are performance improvements to be made, but that can be done in another 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.
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.