bpo-46564: Optimize super().meth() calls via adaptive superinstructions#30992
bpo-46564: Optimize super().meth() calls via adaptive superinstructions#30992Fidget-Spinner wants to merge 11 commits into
super().meth() calls via adaptive superinstructions#30992Conversation
Co-Authored-By: Vladimir Matveev <v2matveev@outlook.com>
|
Marking as draft as I need make this work with the new |
Sorry, something went wrong.
|
Maybe we should merge #31002 first, as that PR is simpler. |
Sorry, something went wrong.
👍 |
Sorry, something went wrong.
|
Mark, I'm going to run benchmarks on |
Sorry, something went wrong.
arhadthedev
left a comment
There was a problem hiding this comment.
A couple of indentation-related inconsistencies:
Sorry, something went wrong.
Well that was depressing. |
Sorry, something went wrong.
|
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.
They should now have almost no overhead over a corresponding
self.meth()call.Summary of changes:
typeobject.c-- refactoring to reuse code during specialization, also useInterpreterFrameoverPyFrameObjectfor lazy frame benefits. Some changes here are partially taken from bpo-43563 : Introduce dedicated opcodes for super calls #24936. All credits to @vladima (I've tried to properly include them in the news item too.)specialize.c-- specialize for the 0-argument and 2-argument form ofsuper().ceval.c-- does both aCALLandLOAD_METHODwithout intermediates (and both are specialized forms too).TODO:
benchmarks!
https://bugs.python.org/issue46564