Hacker GitHub

← All repos

python/cpython

View on GitHub ↗ ★ 77,791 Python

The Python programming language

548 mentions on Hacker News by 400 people: 44 stories, 504 comments · first 2014-12-30 · latest 2026-10-27

Mentions per year 548 mentions · busiest year 2025 (72)
20082026
  1. The central dispatch of the VM is a good place to start: https://github.com/python/cpython/blob/main/Python/ceval.c#L...
    comment by formerly_proven · 2021-10-06 · in Python 3.11: “Zero cost” exception handling
  2. …The Zip format is truly awful. https://en.wikipedia.org/wiki/ZIP_(file_format)#Central_dire... https://github.com/python/cpython/blob/7e465a6b8273dc0b6cb48...
  3. From the python source code: https://github.com/python/cpython/blob/11749e2dc20ad6a76e9a3... It seems to be shelling out to osascript, either telling it to OpenURL or open.
    comment by zirak · 2021-08-16 · in Antigravity.py (2020)
  4. …uses a black-box model to explain it rather than looking at the source, `iadd` uses `extend`: https://github.com/python/cpython/blob/main/Objects/listobje...
  5. …Python implementations that get used if the _operator C module is not available for some reason): https://github.com/python/cpython/blob/3.9/Modules/_operator...
  6. `methodcaller` ( https://github.com/python/cpython/blob/6a6bcf16370beff2e0d1a... ) is just syntax sugar around `getattr` + a function call which is just syntax sugar + default implementation of `__getattr__` which is basically exactly what…
  7. …below, you might as well just be using a def, which is exactly what is done in the operator module: https://github.com/python/cpython/blob/3.9/Lib/operator.py#L... For someone familiar with the operator module, there is a final small…
    comment by randallsquared · 2021-08-08 · in The unknown features of Python's `operator` module
  8. The operator module is very old: https://github.com/python/cpython/blob/ea4d3f0804a3aad5afaa6... PEP8 was introduced in 2001: https://www.python.org/dev/peps/pep-0008/
  9. …does just create a bunch of different Python objects and then use type() to extract their types: https://github.com/python/cpython/blob/v3.9.6/Lib/types.py Some examples from that file: async def _ag(): yield _ag = _ag() AsyncGeneratorType…
    comment by simonw · 2021-07-24 · in How the Python import system works
  10. …3.6 is much more readable than 3.9 so I recommend reading that if you want to see how it works. https://github.com/python/cpython/blob/3.6/Lib/collections/_...
    comment by Spivak · 2021-07-21 · in Namedtuple in a Post-Dataclasses World
  11. See CPython's https://github.com/python/cpython/blob/main/Objects/listsort... for details about the sort. In fact, its "galloping" was inspired by a paper of which Demaine was a co-author (reference in the file already linked to).…
    comment by tim-peters · 2021-07-13 · in Beating TimSort at Merging
  12. Wow. Thanks for writing it. I believe this is the part you are referring to: https://github.com/python/cpython/blob/main/Objects/listobje...
    comment by adamgordonbell · 2021-07-13 · in Beating TimSort at Merging
  13. …be as fast as this implementation? edit: Okay one reason is that heapq.merge is written in python: https://github.com/python/cpython/blob/6252670732c68420c2a8b... It might also be since the python version has more options (like arbitrarily…
    comment by CogitoCogito · 2021-07-13 · in Beating TimSort at Merging
  14. …I'd recommend taking at least a quick look at any python standard library module before using it. https://github.com/python/cpython/tree/main/Lib
  15. This is the complete code (from here: https://github.com/python/cpython/blob/3.9/Lib/statistics.py ) if iter(data) is data: data = list(data) n = len(data) if n < 1: raise StatisticsError('mean requires at least one data point') T, total,…
  16. …of strings, so I added an extra layer of caching, but it looks like it's not needed anymore. [1]: https://github.com/python/cpython/blob/3.10/Objects/unicodeo...
  17. …>>> data = (1_000_000_000.1, 1.1) * 50_000 >>> statistics.fmean(data) 500000000.6 Implementation at https://github.com/python/cpython/blob/6df926f1c46eb6db7b5dc... .
  18. …_sum function for example, which you can see maps _exact_ratio over the data before summing: https://github.com/python/cpython/blob/3.9/Lib/statistics.py...
    comment by _delirium · 2021-06-11 · in How to average floating point numbers (2015)
  19. …may be slower, but I am hoping that it is easy understand why they ought to be preferred. [1]: https://github.com/python/cpython/blob/5571cabf1b3385087aba2... [2]: https://www.nu42.com/2015/03/how-you-average-numbers.html
  20. This has been brought up: https://github.com/python/cpython/pull/26264#discussion_r640... Though personally I would dislike this, since every time somebody mentioned about type hints they commented on the property of them not causing 'ANY…
    comment by treesciencebot · 2021-06-02 · in Making CPython Faster
  21. …Code-ish?[2] Probably not! [1] https://github.com/AdoptOpenJDK/openjdk-jdk11u/blob/master/s... [2] https://github.com/python/cpython/blob/main/Objects/listobje...
  22. …the last month and a few more in flight. I.e the project has already started. See for example https://github.com/python/cpython/pull/25152
  23. Why isn't this hosted at https://github.com/python/cpython/issues ?
  24. This project has already submitted a few small changes into cpython, like https://github.com/python/cpython/pull/25069 and https://github.com/python/cpython/pull/25729
  25. …notes (alongside an explicit statement that it would become default four years later in 3.10): https://github.com/python/cpython/blob/a41782cc84bcd813209a0...
  26. …and it's already no small feat to have added them without breaking backwards compatibility. [0] https://github.com/python/cpython/blob/8a232c7b17a2e41ae14d8...
  27. …cannot assign to literal [0]: https://docs.python.org/3/library/stdtypes.html#float.fromhe... [1]: https://github.com/python/cpython/blob/5ce227f3a767e6e44e7c4... [2]: https://github.com/python/cpython/blob/5ce227f3a767e6e44e7c4...
  28. …It doesn't, since 3.8. It tries fcopyfile() and only if it fails, does the read/write dance. See: https://github.com/python/cpython/blob/master/Lib/shutil.py#...
    comment by vetinari · 2021-04-08 · in Surprisingly Slow
  29. https://github.com/python/cpython/blob/master/Objects/dictob...
    comment by knome · 2021-03-26 · in How to implement a hash table in C
  30. …an attribute that begins with assert Or any of the names in this surprising hardcoded list of typos https://github.com/python/cpython/blob/fdb9efce6ac211f973088...
    comment by progval · 2021-03-25 · in My Python testing style guide (2017)
  31. …Python 3.x being slower than 2.x. [0] https://rubykaigi.org/2016/presentations/tanaka_akr.html [1] https://github.com/python/cpython/blob/8d21aa21f2cbc6d50aab3... [2] https://github.com/python/cpython/blob/39f643614d03748a5fad4...
  32. …pass Here is the C version (with a comment a little way down describing the "fast path advantages": https://github.com/python/cpython/blob/93d33b47af70ede473f82...
  33. …Counter.update instead because I thought linking to the call site is clearer), but here it is: https://github.com/python/cpython/blob/2fe408497e6838b6fb761... Again, very straightforward, based on dict. Python itself does not function at…
  34. …amount of) overhead. Now, dict is optimized, but that's a builtin type. You don't need PSL. https://github.com/python/cpython/blob/2fe408497e6838b6fb761...
  35. …as a performance optimization. Type-specific free lists (just a few examples; there are more): * https://github.com/python/cpython/blob/master/Objects/floato... * https://github.com/python/cpython/blob/master/Objects/tupleo... And also…
    comment by loeg · 2021-03-13 · in Speed of Rust vs. C
  36. Thank you for the pointer. Seems they have already fixed it. https://github.com/python/cpython/pull/24721/files
  37. There's a "Show Source" link in the navigation that points to https://github.com/python/cpython/blob/master/Doc/whatsnew/3...
  38. It's not that powerful, if I'm reading it correctly: https://github.com/python/cpython/commit/34df10a9a16b38d5442... The sprintf is to a temporary buffer that's converted to a PyUnicode object before returning, so subsequent portions of…
  39. …repr'd, an sprintf call with a statically sized buffer of 256 bytes is used to produce a string: https://github.com/python/cpython/commit/d9b8f138b7df3b455b54653ca59f491b4840d6fa#diff-4e23b3237d0aa08bf4c434d75fab19200a80837bd147051fefccd98b…
  40. For reference, here is the live copy of longobject.c: https://github.com/python/cpython/blob/master/Objects/longob... Python 2 had distinct `int` and `long` types, but Python 3 merged them together into just `int`. I wasn't sure if the…
  41. https://github.com/python/cpython/commit/b71c7dc9ddd6997be49... commit b71c7dc9ddd6997be49ed6aaabf99a067e2c0388 Author: Victor Stinner <victor.stinner@gmail.com> Date: Fri Oct 10 11:55:41 2014 +0200 Issue #22591: Drop support of MS-DOS…
    comment by eesmith · 2021-01-24 · in Pip has dropped support for Python 2
  42. …treated as a format string _if_ there are arguments. If not, it is treated as a literal string: https://github.com/python/cpython/blob/dcea78ff53d02733ac598...
  43. PyCon totally does affect python.tar.gz. https://github.com/python/cpython/pulls?q=+label%3Asprint (and that link doesn’t capture the PEPs hashed out among other things.) Also, why the hell make a new account for each comment?
  44. …for macOS 11 and Apple Silicon count? Here's a list of Apple-submitted PRs on python/cpython: https://github.com/python/cpython/pulls?q=is%3Apr+author%3Al... Also some co-authored patches excluded by the search. See…
  45. …is part of the standard library, and was part of the standard library in 3.0, and contained reduce: https://github.com/python/cpython/blob/3.0/Lib/functools.py#... What he meant to say is that it's removed from the list of builtins.
  46. Python's developers must have enormous heads if that's the case: https://github.com/python/cpython/blob/b8fde8b5418b75d2935d0...
    comment by brobinson · 2020-12-21 · in Write code. Not too much. Mostly functions.
  47. There are fast-paths for these cases, like this one: https://github.com/python/cpython/blob/4b8cdfcb22fbeaab9d954... (and note the comment above it about integer addition!) But the cpython folk make understandability an explicit goal of…
    comment by ketralnis · 2020-12-11 · in How the Python object system works
  48. Thanks. So it seems both were updated with 'key' at the same time: https://github.com/python/cpython/commit/871934d4cf00687b3d1... Now I'm wondering - what is the point of the python version, if it will always be overridden by the C…
    comment by rahimnathwani · 2020-11-23 · in Using Python's Bisect Module
  49. …is in Modules/_bisectmodule.c, whereas the Python version is in Lib/bisect.py. Python version: https://github.com/python/cpython/blob/master/Lib/bisect.py C version: https://github.com/python/cpython/blob/master/Modules/_bisec...
    comment by kaunta · 2020-11-22 · in Using Python's Bisect Module
  50. https://github.com/python/cpython/blob/master/Lib/bisect.py
    comment by rahimnathwani · 2020-11-22 · in Using Python's Bisect Module