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. You don't have to find an alternative. Just copy the parts you need into your own code: https://github.com/python/cpython/blob/main/Lib/cgi.py
    comment by iso8859-1 · 2022-03-18 · in Python finally offloads some batteries
  2. …more than just a single hardware add per Python "add." You can see the actual implementation here: https://github.com/python/cpython/blob/main/Objects/longobje... You've got multiple for loops over every digit, array dereferencing, plus…
  3. ▲ 2
    CPython Listsort (Timsort)
    story by addcninblue · 2022-03-09 · 0 comments
  4. Python is similar[1] >The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, ... https://github.com/python/cpython/blob/3.7/Objects/listobjec...
  5. CPython appears to use a PEG parser for its implementation: https://github.com/python/cpython/blob/b77158b4da449ec5b8f68...
    comment by linux2647 · 2022-02-20 · in Things that used to be hard and are now easy
  6. ▲ 3
    Hash Array Mapped Trie (HAMT) Datastructure
    story by pxeger1 · 2022-02-17 · 0 comments
  7. …the value of `exit` if you so choose. "Special cases aren't special enough to break the rules." [1] https://github.com/python/cpython/blob/06b8f1615b09099fae5c5...
    comment by luhn · 2022-02-06 · in What's in a good error message?
  8. > CPython does not do these things. Again, it is. https://github.com/python/cpython/blob/2d080347d74078a55c477... This is the memmove() I mentioned above. Like, I actually perf-d the code and confirmed this is in the hot loop. > but 1553D…
  9. Hmm, it looks like it’s handled comments for at least a decade: https://github.com/python/cpython/blame/d75a51bea3c2442f81d3... Oh, maybe it’s this issue: https://bugs.python.org/issue34132 If I’ve read it correctly, there was a regression…
  10. …handled alternative. I filed a PR with a proposed documentation improvement in mid December: https://github.com/python/cpython/pull/30142 Apart from one drive-by comment from a non-core contributor, no-one has commented on the pull request…
  11. …is implemented by constructing _string representations_ of functions and calling `exec` on them. https://github.com/python/cpython/blob/3.10/Lib/dataclasses.... Kind of blew my mind
  12. …else (if it even throws anything else?) to be fatal. This is the same way cpython handles it: https://github.com/python/cpython/blob/b56774bd93822e1598bb5... The context manager idea sounds good, but I think that might require a lot of…
  13. Python's csv imports _csv for core functionality, which is C: https://github.com/python/cpython/blob/main/Modules/_csv.c
  14. …ps://github.com/php/php-src/blob/1c0e613cf1a24cdc159861e4... - Python's C implementation is the same: https://github.com/python/cpython/blob/main/Modules/_csv.c - Java doesn't have a "standard" way at all (…
    comment by mschuster91 · 2021-12-16 · in Leveraging SIMD: Splitting CSV Files at 3Gb/S
  15. The `eval()` in the namedtuple factory function[1] makes it a bit kludgy, IMO. [1]: https://github.com/python/cpython/blob/3.10/Lib/collections/...
    comment by woadwarrior01 · 2021-12-12 · in The Data Classes Decorator
  16. …random probes or by chasing linked list references to random memory locations for each link. https://github.com/python/cpython/blob/f840398a5fd8741653c26...
    comment by raymondh · 2021-11-23 · in A Tale of Java Hash Tables
  17. …more to say about how list resizing works than is immediately obvious. The relevant source is here: https://github.com/python/cpython/blob/main/Objects/listobje... As the article points out, the size progression, as detailed in the comment…
    comment by kgm · 2021-11-14 · in How Python List Works
  18. How a Python list really works? See the underlying C implementation: https://github.com/python/cpython/blob/main/Objects/listobje... ; https://github.com/python/cpython/blob/main/Include/listobje... For comparison, java.util.ArrayList is…
    comment by nayuki · 2021-11-14 · in How Python List Works
  19. …they can easily determine they are the exclusive owner by checking for a reference count of 1. See: https://github.com/python/cpython/blob/main/Objects/unicodeo... Rust's ownership system ensures that there cannot exist mutable and…
    comment by MarkSweep · 2021-11-14 · in A terrible schema from a clueless programmer
  20. …to work with. The setup takes no effort at all and it "just works", batteries included, via ctypes. https://github.com/python/cpython/blob/main/Lib/multiprocess...
  21. …-- it reads as if it will only kick in on linux if it detects a sufficiently new version of glibc: https://github.com/python/cpython/blob/main/Lib/subprocess.p... edit: Python 3.10 now supports using vfork for linux inside subprocess:…
  22. …or not CPython doesn't have a JIT, it has an interpreter. So it spends a lot of time in this loop: https://github.com/python/cpython/blob/main/Python/ceval.c But you still have a repl with pypy. The downsides of JIT is that compiling…
  23. Correct link: https://github.com/python/cpython/blob/3.10/Lib/turtle.py#L3...
    comment by danbst · 2021-11-03 · in A German Easter Egg in Python Turtle
  24. ▲ 1
    A German Easter Egg in Python Turtle
    story by danbst · 2021-11-03 · 1 comment
  25. …com/clap-rs/clap/pull/1637#issuecomment-58103... [1] https://tldp.org/LDP/abs/html/exitcodes.html [2] https://github.com/python/cpython/blob/main/Lib/argparse.py#...
  26. …I can cheat and copy anyway since only the non-refcounted ones are allowed in them. [0] https://github.com/python/cpython/blob/main/Include/object.h...
    comment by sizediterable · 2021-10-29 · in Building an Emacs Lisp VM in Rust
  27. I meant actual code from their library So https://github.com/python/cpython/tree/main/Python
    comment by savant_penguin · 2021-10-25 · in To learn a new language, read its standard library
  28. re depends ultimately of this c file https://github.com/python/cpython/blob/main/Modules/_sre.c
    comment by makapuf · 2021-10-08 · in Faster Python with Guido van Rossum
  29. 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
  30. …The Zip format is truly awful. https://en.wikipedia.org/wiki/ZIP_(file_format)#Central_dire... https://github.com/python/cpython/blob/7e465a6b8273dc0b6cb48...
  31. 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)
  32. ▲ 116
    Antigravity.py (2020)
    story by chha · 2021-08-16 · 43 comments
  33. …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...
  34. …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...
  35. `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…
  36. …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
  37. 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/
  38. …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
  39. …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
  40. 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
  41. 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
  42. …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
  43. …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
  44. 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,…
  45. …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...
  46. …>>> data = (1_000_000_000.1, 1.1) * 50_000 >>> statistics.fmean(data) 500000000.6 Implementation at https://github.com/python/cpython/blob/6df926f1c46eb6db7b5dc... .
  47. …_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)
  48. …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
  49. 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
  50. …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...