Visitar URL original
slowdown in 3.12 iteration microbenchmark · Issue #113041 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20250610103805/https://github.com/python/cpython/issues/113041
Skip to content

slowdown in 3.12 iteration microbenchmark #113041

Open
@ajoino

Description

@ajoino

Bug report

Bug description:

I decided to install 3.12 from deadsnakes to play around and test how much faster some simple code would be with the inlined comprehensions (got inspired after listening to Carl's appearance in the core.py podcast.)

I tried running this code with both 3.11.7 and 3.12.1

import timeit

res = timeit.timeit("[a * 2 for a in range(1_000_000)]", number=100)

print(f"{res = }")

and I consistently get a time of around 2.8 seconds for 3.11 and a time of around 2.9 - 3.1 seconds on 3.12.
The variability for 3.11 was around 0.06 seconds and for 3.12 was around 0.2 seconds.

Not sure if this is to be expected considering the large changes made between versions, but intuitively this example should at least not be worse I think?

CPython versions tested on:

3.11, 3.12

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance or resource usagetype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions