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-46564: Optimize ``super().meth()`` calls via adaptive superinstructions by Fidget-Spinner · Pull Request #30992 · python/cpython Conversation
|
|
Marking as draft as I need make this work with the new |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
|
||
| DEOPT_IF(_PyType_CAST(super_callable) != &PySuper_Type, CALL); | ||
| /* super() - zero argument form */ | ||
| if (_PySuper_GetTypeArgs(frame, frame->f_code, &su_type, &su_obj) < 0) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can't we do this at specialization time? The number of locals, the index of "self", and whether it is a cell are all known then. Likewise the nature of __class__ is also known.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
| assert(su_obj != NULL); | ||
| DEOPT_IF(lm_adaptive->version != Py_TYPE(su_obj)->tp_version_tag, CALL); | ||
| DEOPT_IF(cache0->version != su_type->tp_version_tag, CALL); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
When can this fail?
Isn't the next item in the MRO determined solely by type(self) and __class__, both of which are known at this point?
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 a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I wanted assurance that __class__ didn't change.. Then again, I'm not sure if it can?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Maybe we should merge #31002 first, as that PR is simpler. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
👍 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Mark, I'm going to run benchmarks on |
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.
A couple of indentation-related inconsistencies:
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| super_init_without_args(InterpreterFrame *cframe, PyCodeObject *co, | ||
| int | ||
| _PySuper_GetTypeArgs(InterpreterFrame *cframe, PyCodeObject *co, | ||
| PyTypeObject **type_p, PyObject **obj_p) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| PyTypeObject **type_p, PyObject **obj_p) | |
| PyTypeObject **type_p, PyObject **obj_p) |
The line was aligned with an opening parenthesis of a parameter list.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| PyObject *kwnames, SpecializedCacheEntry *cache, PyObject *builtins, | ||
| PyObject **stack_pointer, InterpreterFrame *frame, PyObject *names); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| PyObject *kwnames, SpecializedCacheEntry *cache, PyObject *builtins, | |
| PyObject **stack_pointer, InterpreterFrame *frame, PyObject *names); | |
| PyObject *kwnames, SpecializedCacheEntry *cache, PyObject *builtins, | |
| PyObject **stack_pointer, InterpreterFrame *frame, PyObject *names); |
as in a removed line, or even:
| PyObject *kwnames, SpecializedCacheEntry *cache, PyObject *builtins, | |
| PyObject **stack_pointer, InterpreterFrame *frame, PyObject *names); | |
| PyObject *kwnames, SpecializedCacheEntry *cache, PyObject *builtins, | |
| PyObject **stack_pointer, InterpreterFrame *frame, PyObject *names); |
as in _Py_Specialize_BinaryOp right below.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Well that was depressing. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Microbenchmarks show that import timeit setup = """ class A: def f(self): pass class B(A): def g(self): super().f() def h(self): self.f() b = B() """ # super() call print(timeit.timeit("b.g()", setup=setup, number=20_000_000)) # reference print(timeit.timeit("b.h()", setup=setup, number=20_000_000)) Results: So |
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.