# \#performance

**URL:** https://discuss.python.org/tag/performance/49.md

[Latest](https://discuss.python.org/latest.md) · [Categories](https://discuss.python.org/categories.md) · [Tags](https://discuss.python.org/tags.md)

---

## [Optimization for insertdict()](https://discuss.python.org/t/optimization-for-insertdict/109348)

<div class="topic-metadata">

**Author:** [@hetaozdh](https://discuss.python.org/u/hetaozdh)\
**Replies:** 3\
**Last updated:** [October 5, 2026, 8:48am UTC](https://discuss.python.org/t/optimization-for-insertdict/109348 "2026-10-05T08:48:07Z")

</div>

insertdict() (dictobject.c:2051) first calls \_Py\_dict\_lookup() (dictobject.c:2071). On a miss, it then calls insert\_combined\_dict() (dictobject.c:1902), which calls find\_empty\_slot() (dictobject.c:1924) and probes the ta…

---

## [Python 3.11 and Function Call Frequency](https://discuss.python.org/t/python-3-11-and-function-call-frequency/108013)

<div class="topic-metadata">

**Author:** [@adrianofdoom](https://discuss.python.org/u/adrianofdoom)\
**Replies:** 36\
**Last updated:** [July 20, 2026, 5:50pm UTC](https://discuss.python.org/t/python-3-11-and-function-call-frequency/108013 "2026-07-20T17:50:03Z")

</div>

My cProfile profiling run time has gone from 1.5 - 2.5 times normal execution speed in python3.9 to 10 times or more in python 3.11 and 3.14. Google says it’s because of PEP 659 and cites " Function Call Frequency" a…

---

## [Correct way to use timeit and why its giving me wrong incorrect timings](https://discuss.python.org/t/correct-way-to-use-timeit-and-why-its-giving-me-wrong-incorrect-timings/108147)

<div class="topic-metadata">

**Author:** [@BadDreams34](https://discuss.python.org/u/BadDreams34)\
**Replies:** 4\
**Last updated:** [July 15, 2026, 6:01am UTC](https://discuss.python.org/t/correct-way-to-use-timeit-and-why-its-giving-me-wrong-incorrect-timings/108147 "2026-07-15T06:01:01Z")

</div>

i m not understanding the correct way to use timeit and should i measure performance with timeit rather than big(O)s ? the main confusion i have is is timeit module used to test time like this ? how i m using it : View…

---

## [Can the bytecode optimization code be farmed out to LLVM?](https://discuss.python.org/t/can-the-bytecode-optimization-code-be-farmed-out-to-llvm/108140)

<div class="topic-metadata">

**Author:** [@SurenNihalani](https://discuss.python.org/u/SurenNihalani)\
**Replies:** 3\
**Last updated:** [July 13, 2026, 9:28pm UTC](https://discuss.python.org/t/can-the-bytecode-optimization-code-be-farmed-out-to-llvm/108140 "2026-07-13T21:28:35Z")

</div>

I was looking for issues to help with under performance. I noticed this pattern amongst some issues: gh-152215: Add uop peepholes for folded stack shuffles by cocolato · Pull Request #153035 · python/cpython · GitHub \`…

---

## [News faster CPython, JIT and 3.14](https://discuss.python.org/t/news-faster-cpython-jit-and-3-14/85326)

<div class="topic-metadata">

**Author:** [@paugier](https://discuss.python.org/u/paugier)\
**Replies:** 28\
**Last updated:** [June 30, 2026, 11:46am UTC](https://discuss.python.org/t/news-faster-cpython-jit-and-3-14/85326 "2026-06-30T11:46:36Z")

</div>

I worked a bit on studying the effect of the new CPython JIT and more generally of performance for simple CPU bounded pure Python code. I focused on a very simple benchmark involving only very simple pure Python: def s…

---

## [BehaviorEnum: an Enum subclass that bundles a value with a callable - stdlib candidate?](https://discuss.python.org/t/behaviorenum-an-enum-subclass-that-bundles-a-value-with-a-callable-stdlib-candidate/106750)

<div class="topic-metadata">

**Author:** [@thevivekdwivedi](https://discuss.python.org/u/thevivekdwivedi)\
**Replies:** 27\
**Last updated:** [April 6, 2026, 7:01am UTC](https://discuss.python.org/t/behaviorenum-an-enum-subclass-that-bundles-a-value-with-a-callable-stdlib-candidate/106750 "2026-04-06T07:01:44Z")

</div>

The problem A common pattern is dispatching to different behavior based on an enum member. Two approaches dominate: if/elif (or match/case): Dispatch logic is coupled away from the enum definition Adding a member requ…

---

## [Memory-Efficient Dictionary via Elastic Hashing (Achieving 40%+ RAM savings at high load factors)](https://discuss.python.org/t/memory-efficient-dictionary-via-elastic-hashing-achieving-40-ram-savings-at-high-load-factors/106194)

<div class="topic-metadata">

**Author:** [@bueno1222](https://discuss.python.org/u/bueno1222)\
**Replies:** 26\
**Last updated:** [March 21, 2026, 9:38am UTC](https://discuss.python.org/t/memory-efficient-dictionary-via-elastic-hashing-achieving-40-ram-savings-at-high-load-factors/106194 "2026-03-21T09:38:11Z")

</div>

Introduction Hi everyone, I’ve been exploring the practical implications of the recent paper “Optimal Bounds for Open Addressing Without Reordering” (Farach-Colton et al., arXiv:2501.02305, Jan 2025). I’ve developed a P…

---

## [Why did cProfile crash?](https://discuss.python.org/t/why-did-cprofile-crash/105960)

<div class="topic-metadata">

**Author:** [@rokejulianlockhart](https://discuss.python.org/u/rokejulianlockhart)\
**Replies:** 2\
**Last updated:** [February 1, 2026, 9:52pm UTC](https://discuss.python.org/t/why-did-cprofile-crash/105960 "2026-02-01T21:52:12Z")

</div>

What I Did For github.com/Crozzers/screen\_brightness\_control/issues/25#issuecomment-3832118702, I attempted to do as stackoverflow.com/revisions/582337/10 advises: #!/usr/bin/env sh python3.15 Python 3.15.0a5 …

---

## [Best practice for collecting perf stat counters for pyperformance benchmarks without including harness overhead?](https://discuss.python.org/t/best-practice-for-collecting-perf-stat-counters-for-pyperformance-benchmarks-without-including-harness-overhead/105803)

<div class="topic-metadata">

**Author:** [@113xiaoji](https://discuss.python.org/u/113xiaoji)\
**Replies:** 0\
**Last updated:** [January 20, 2026, 2:41am UTC](https://discuss.python.org/t/best-practice-for-collecting-perf-stat-counters-for-pyperformance-benchmarks-without-including-harness-overhead/105803 "2026-01-20T02:41:12Z")

</div>

Hi all, I’m trying to use perf stat hardware counters (e.g. instructions, L1-icache-misses) together with pyperformance to understand micro-architectural effects (e.g. code layout / I-cache behavior). I noticed some exp…

---

## [Add zero-copy conversion of \`bytearray\` to \`bytes\` by providing \`\_\_bytes\_\_()\`](https://discuss.python.org/t/add-zero-copy-conversion-of-bytearray-to-bytes-by-providing-bytes/79164)

<div class="topic-metadata">

**Author:** [@cmaloney](https://discuss.python.org/u/cmaloney)\
**Replies:** 70\
**Last updated:** [January 15, 2026, 5:40pm UTC](https://discuss.python.org/t/add-zero-copy-conversion-of-bytearray-to-bytes-by-providing-bytes/79164 "2026-01-15T17:40:06Z")

</div>

Currently to be efficient in Python, a “zero copy” / “zero extra memory” pure-python I/O loop needs to: Use a mutable buffer of bytes (bytearray) buf = bytearray(BUFFER\_SIZE) Fill it using file.readinto(buf)/os.readint…

---

## [Python 3.15 JIT benchmarks](https://discuss.python.org/t/python-3-15-jit-benchmarks/105678)

<div class="topic-metadata">

**Author:** [@commongeek](https://discuss.python.org/u/commongeek)\
**Replies:** 3\
**Last updated:** [January 13, 2026, 3:18pm UTC](https://discuss.python.org/t/python-3-15-jit-benchmarks/105678 "2026-01-13T15:18:59Z")

</div>

“The speedups for JIT builds versus no JIT builds range from roughly 20% slowdown to over 100% speedup (ignoring the unpack\_sequence microbenchmark) on x86-64 Linux and AArch64 macOS systems.” (Quote from preview release…

---

## [Guidelines for acceptable performance optimizations?](https://discuss.python.org/t/guidelines-for-acceptable-performance-optimizations/105506)

<div class="topic-metadata">

**Author:** [@heikkitoivonen](https://discuss.python.org/u/heikkitoivonen)\
**Replies:** 6\
**Last updated:** [January 9, 2026, 8:16pm UTC](https://discuss.python.org/t/guidelines-for-acceptable-performance-optimizations/105506 "2026-01-09T20:16:47Z")

</div>

Python has been my main language since 2003, and I figured I should finally try to contribute directly to the language itself. My first idea was that I would look for simple micro-optimization ideas in the stdlib. My fir…

---

## [How did you make such huge performance gains?](https://discuss.python.org/t/how-did-you-make-such-huge-performance-gains/105268)

<div class="topic-metadata">

**Author:** [@beauxq](https://discuss.python.org/u/beauxq)\
**Replies:** 2\
**Last updated:** [December 12, 2025, 10:35am UTC](https://discuss.python.org/t/how-did-you-make-such-huge-performance-gains/105268 "2025-12-12T10:35:00Z")

</div>

This isn’t really a request for help, but I didn’t find a more appropriate section to just comment. I recently added 3.14 to my CI, and then I saw this: My first suspicion was that Github was allocating more CPU to …

---

## [Performance regression from using \`email.message.Message.get\_params()\` as replacement of \`cgi.parse\_header\` following PEP 594](https://discuss.python.org/t/performance-regression-from-using-email-message-message-get-params-as-replacement-of-cgi-parse-header-following-pep-594/99963)

<div class="topic-metadata">

**Author:** [@nessita](https://discuss.python.org/u/nessita)\
**Replies:** 8\
**Last updated:** [September 4, 2025, 8:36pm UTC](https://discuss.python.org/t/performance-regression-from-using-email-message-message-get-params-as-replacement-of-cgi-parse-header-following-pep-594/99963 "2025-09-04T20:36:32Z")

</div>

Hello everyone! PEP 594 deprecated the cgi module and scheduled it for removal in Python 3.13. The PEP recommends email.message.Message().get\_params() as a replacement for cgi.parse\_header(), giving the following exampl…

---

## [Using Clang-CL for Better Performance on Windows on ARM](https://discuss.python.org/t/using-clang-cl-for-better-performance-on-windows-on-arm/96130)

<div class="topic-metadata">

**Author:** [@Akash9824](https://discuss.python.org/u/Akash9824)\
**Replies:** 12\
**Last updated:** [July 1, 2025, 4:36pm UTC](https://discuss.python.org/t/using-clang-cl-for-better-performance-on-windows-on-arm/96130 "2025-07-01T16:36:26Z")

</div>

I am writing to discuss the potential of using clang-cl as the default compiler for Windows on ARM (WOA) devices to ensure consistent performance across platforms. Given its widespread acceptance in iOS devices with ARM …

---

## [Who works on digital sustainability in the Python world?](https://discuss.python.org/t/who-works-on-digital-sustainability-in-the-python-world/66890)

<div class="topic-metadata">

**Author:** [@thibaudcolas](https://discuss.python.org/u/thibaudcolas)\
**Replies:** 21\
**Last updated:** [June 20, 2025, 12:22pm UTC](https://discuss.python.org/t/who-works-on-digital-sustainability-in-the-python-world/66890 "2025-06-20T12:22:29Z")

</div>

I was at a tech un-conference today and there were a couple Python people in discussions about digital environmental sustainability (of the web specifically but also interested in other areas). This made me wonder who el…

---

## [Performance of chained operations on numpy arrays](https://discuss.python.org/t/performance-of-chained-operations-on-numpy-arrays/95142)

<div class="topic-metadata">

**Author:** [@QEng](https://discuss.python.org/u/QEng)\
**Replies:** 9\
**Last updated:** [June 11, 2025, 7:44pm UTC](https://discuss.python.org/t/performance-of-chained-operations-on-numpy-arrays/95142 "2025-06-11T19:44:54Z")

</div>

Hi, At work we have a model that computes: # Version A x = a / b \* c Where a, b, and c are typically numpy arrays with floats of size 100k. Because this is the main place we spend time, we experimented a bit and separ…

---

## [Question about JIT performance improvement](https://discuss.python.org/t/question-about-jit-performance-improvement/94776)

<div class="topic-metadata">

**Author:** [@NoAnyLove](https://discuss.python.org/u/NoAnyLove)\
**Replies:** 2\
**Last updated:** [June 7, 2025, 11:46pm UTC](https://discuss.python.org/t/question-about-jit-performance-improvement/94776 "2025-06-07T23:46:37Z")

</div>

As a long-term Python user, I closely follow the updates of Python performance improvement. According to benchmarking-public/RESULTS.md at main · faster-cpython/benchmarking-public · GitHub, the JIT performance has great…

---

## [Python // vs. divmod?](https://discuss.python.org/t/python-vs-divmod/93919)

<div class="topic-metadata">

**Author:** [@CyrusPolentschz](https://discuss.python.org/u/CyrusPolentschz)\
**Replies:** 11\
**Last updated:** [May 30, 2025, 11:55pm UTC](https://discuss.python.org/t/python-vs-divmod/93919 "2025-05-30T23:55:38Z")

</div>

I have these functions that are intended to find all the prime divisors of every number from 2 to n: from time import time start = time() primes = \[\] def primedivs1(n): global primes primedivs = \[\] a =…

---

## [Add control flow callbacks for JIT-compiled frameworks](https://discuss.python.org/t/add-control-flow-callbacks-for-jit-compiled-frameworks/75636)

<div class="topic-metadata">

**Author:** [@MRiabov](https://discuss.python.org/u/MRiabov)\
**Replies:** 12\
**Last updated:** [May 13, 2025, 5:08pm UTC](https://discuss.python.org/t/add-control-flow-callbacks-for-jit-compiled-frameworks/75636 "2025-05-13T17:08:01Z")

</div>

Hello Python community, First - I’ll say that python is the best language in the world, but it’s quite difficult to make it performant (as everybody knows). So we have come up with a just-in-time compilation for perfor…

---

## [Python 3.14.0a7 - Slow functions when including try-except statement](https://discuss.python.org/t/python-3-14-0a7-slow-functions-when-including-try-except-statement/89520)

<div class="topic-metadata">

**Author:** [@Wouks](https://discuss.python.org/u/Wouks)\
**Replies:** 1\
**Last updated:** [April 24, 2025, 10:25pm UTC](https://discuss.python.org/t/python-3-14-0a7-slow-functions-when-including-try-except-statement/89520 "2025-04-24T22:25:01Z")

</div>

I have run into a case where it seems Python 3.14 (alpha) runs slower when there is a try-except within the function. It seems to be slower even if the exception never occurs/raised which is odd. This is the code that I…

---

## [High-performance Asyncio networking: sockets vs streams vs protocols](https://discuss.python.org/t/high-performance-asyncio-networking-sockets-vs-streams-vs-protocols/73420)

<div class="topic-metadata">

**Author:** [@NoahStapp](https://discuss.python.org/u/NoahStapp)\
**Replies:** 10\
**Last updated:** [December 23, 2024, 3:32pm UTC](https://discuss.python.org/t/high-performance-asyncio-networking-sockets-vs-streams-vs-protocols/73420 "2024-12-23T15:32:15Z")

</div>

I’ve working on writing high-performance asyncio network code and after having tried all three of the available APIs, I’m wondering if I’m writing my code incorrectly. The official docs suggest that working with socket …

---

## [numpy array access   ](https://discuss.python.org/t/numpy-array-access/26878)

<div class="topic-metadata">

**Author:** [@uhcdd](https://discuss.python.org/u/uhcdd)\
**Replies:** 7\
**Last updated:** [December 2, 2024, 9:14am UTC](https://discuss.python.org/t/numpy-array-access/26878 "2024-12-02T09:14:49Z")

</div>

Hello everybody, have N = 1000 A = zeros((N), dtype=float) B = zeros((N), dtype=float) C = zeros((N), dtype=float) Fill B, C with some data. What is the difference between A = B+C and A\[:\] = B\[:\]+C\[:\] Might th…

---

## [Enable dictionary constructor to compute values concurrently](https://discuss.python.org/t/enable-dictionary-constructor-to-compute-values-concurrently/72937)

<div class="topic-metadata">

**Author:** [@vivodi](https://discuss.python.org/u/vivodi)\
**Replies:** 4\
**Last updated:** [December 1, 2024, 3:30pm UTC](https://discuss.python.org/t/enable-dictionary-constructor-to-compute-values-concurrently/72937 "2024-12-01T15:30:35Z")

</div>

The following code takes 4 seconds to run. If the dictionary constructor compute its values concurrently, it only takes 2 seconds. import asyncio import time async def main(): start = time.time() d = { …

---

## [Why python in Debian Docker image is faster than official Docker's python image?](https://discuss.python.org/t/why-python-in-debian-docker-image-is-faster-than-official-dockers-python-image/53976)

<div class="topic-metadata">

**Author:** [@fabien-michel](https://discuss.python.org/u/fabien-michel)\
**Replies:** 11\
**Last updated:** [May 23, 2024, 7:20am UTC](https://discuss.python.org/t/why-python-in-debian-docker-image-is-faster-than-official-dockers-python-image/53976 "2024-05-23T07:20:17Z")

</div>

Hi, Debian’s python installed inside a docker container is faster than the official python from docker. How is it possible ? # Dockerfile-debian FROM debian:sid RUN apt update && apt install -y python3.12 # Python cod…

---

## [Profiling applications with decorators - how to improve decorator names](https://discuss.python.org/t/profiling-applications-with-decorators-how-to-improve-decorator-names/47885)

<div class="topic-metadata">

**Author:** [@JLowe-N](https://discuss.python.org/u/JLowe-N)\
**Replies:** 0\
**Last updated:** [March 7, 2024, 3:08pm UTC](https://discuss.python.org/t/profiling-applications-with-decorators-how-to-improve-decorator-names/47885 "2024-03-07T15:08:04Z")

</div>

I have been using some of the typical profiling tools to profile my web application - cprofile, yappi, etc. The application has a fair amount of decorator reuse across the application, but one side effect of this reuse …

---

## [Performance of str.encode vs codecs.getwriter](https://discuss.python.org/t/performance-of-str-encode-vs-codecs-getwriter/45949)

<div class="topic-metadata">

**Author:** [@davetapley](https://discuss.python.org/u/davetapley)\
**Replies:** 9\
**Last updated:** [February 14, 2024, 10:37pm UTC](https://discuss.python.org/t/performance-of-str-encode-vs-codecs-getwriter/45949 "2024-02-14T22:37:27Z")

</div>

For reasons\* I need to get from a json.dump to BytesIO. My first thought was: out = io.BytesIO(json.dumps(data).encode('utf-8')) But it occurred to me that json.dump accepts SupportsWrite\[str\] aka StringIO, and this …

---

## [How much memory does using "from xxx import \*" use](https://discuss.python.org/t/how-much-memory-does-using-from-xxx-import-use/44553)

<div class="topic-metadata">

**Author:** [@c-rob](https://discuss.python.org/u/c-rob)\
**Replies:** 9\
**Last updated:** [January 31, 2024, 2:11am UTC](https://discuss.python.org/t/how-much-memory-does-using-from-xxx-import-use/44553 "2024-01-31T02:11:12Z")

</div>

My eventual config will use Microsoft Azure to make a web app. The virtual machine that will run this will likely have limited memory. We are charged for both storage and something I can’t remember but which is like run…

---

## [Add \`key\` argument to \`tuple.index()\`](https://discuss.python.org/t/add-key-argument-to-tuple-index/42625)

<div class="topic-metadata">

**Author:** [@grigoriev-semyon](https://discuss.python.org/u/grigoriev-semyon)\
**Replies:** 18\
**Last updated:** [January 7, 2024, 11:34pm UTC](https://discuss.python.org/t/add-key-argument-to-tuple-index/42625 "2024-01-07T23:34:27Z")

</div>

It would be useful to search a tuple in a functional-style manner # tuple with structured data data = ((1, 2), (2, 3)) # find index of 2 in classic manner: for idx, item in enumerate(data): if item\[1\] == 2: …

---

## [Make several attributes stores a SINGLE instruction](https://discuss.python.org/t/make-several-attributes-stores-a-single-instruction/42035)

<div class="topic-metadata">

**Author:** [@mahdihaghverdi](https://discuss.python.org/u/mahdihaghverdi)\
**Replies:** 9\
**Last updated:** [January 6, 2024, 7:55am UTC](https://discuss.python.org/t/make-several-attributes-stores-a-single-instruction/42035 "2024-01-06T07:55:52Z")

</div>

Explanation I’ve been exploring the PEP series on with statement in Python, which I found something interesting about VB language, the VB’s with statement, with which you can do this: With theCustomer .Name = "Coho …

[Next page](https://discuss.python.org/tag/performance/49.md?match_all_tags=true&page=1&tags%5B%5D=performance)
