◐ Shell
clean mode source ↗

gh-90699: Use module state to access insert str object. by corona10 · Pull Request #91693 · python/cpython

import pyperf

runner = pyperf.Runner()
runner.timeit(name="bench bisect",
              stmt="""
bisect.insort(a, 30)
""",
              setup = """

import bisect

class A(list):
    pass

a = A(range(1000))
"""
              )

Mean +- std dev: [main] 1.14 us +- 0.01 us -> [module] 1.06 us +- 0.01 us: 1.07x faster