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
20082026
-
…in Python since each comparison can call a Python function) so all numbers are given as such. [1] https://github.com/python/cpython/blob/main/Objects/listsort...
comment by lifthrasiir · 2022-07-29 · in Timsort (2019) -
…ever read how time libraries are actually written? Please, go read the Python `datetime` library: https://github.com/python/cpython/blob/0fe645d6fd22a6f57e777... which is used to calculate a UTC timestamp:…
comment by lelandbatey · 2022-07-27 · in It’s time to leave the leap second in the past -
…Python ought to be portable across Python implementations. I was merely pointing out that this line https://github.com/python/cpython/blob/4395ff1e6a18fb26c7a66... isn’t exactly pure Python, because, under a different runtime (eg PyPy),…
comment by Bogdanp · 2022-07-26 · in Performance comparison: counting words in Python, C/C++, Awk, Rust, and more -
…`dict` type. I don't think it's comparable to something like using `pandas` to solve the problem. https://github.com/python/cpython/blob/main/Lib/collections/...
comment by __marvin_the__ · 2022-07-24 · in Performance comparison: counting words in Python, C/C++, Awk, Rust, and more -
…to the head. And it is in fact implemented as a doubly linked list, with various optimizations: https://github.com/python/cpython/blob/v3.8.1/Modules/_colle... .
comment by foolswisdom · 2022-07-22 · in Ask HN: What are some cool but obscure data structures you know about? -
…Documentation still hasn't been written for it yet though and that's why the issue is still open, https://github.com/python/cpython/issues/90908 .
comment by Mehdi2277 · 2022-06-27 · in What's New in Python 3.11? -
…module uses HTTP/1.1 and includes a "Connection:close" header in its HTTP requests" [1] [1] https://github.com/python/cpython/blob/3.10/Lib/urllib/reque... You seem to be correct about urllib3 and requests, I was wrong there...though they…
comment by tyingq · 2022-06-21 · in Get Paid to Contribute to Urllib3 -
…module is imported and the enable function is called. [1]: https://peps.python.org/pep-0523/ [2]: https://github.com/python/cpython/blob/main/Python/ceval.c
comment by woadwarrior01 · 2022-06-08 · in Pyston-lite: our Python JIT as an extension module -
…it's been nothing on the beta branch, I think. For example this PR is not getting merged, it seems. https://github.com/python/cpython/pull/93379
comment by kzrdude · 2022-06-06 · in Python 3.11 Performance Benchmarks Are Looking Fantastic -
…core devs. This wasn't the case, just a few years ago. [1]: https://peps.python.org/pep-0659/ [2]: https://github.com/python/cpython/blob/main/Python/ceval.c
comment by woadwarrior01 · 2022-06-06 · in Python 3.11 Performance Benchmarks Are Looking Fantastic -
The rationale was here. https://github.com/python/cpython/issues/85067#issuecomment-... It seems a bit vague: « Exposing this attribute would help with introspection, making it possible to write efficient functions that operate on dict…
comment by mjw1007 · 2022-05-21 · in Python Standard Library changes in recent years -
…here is 32 bits), which calls _Py_popcount32, which does map to a hardware instruction if possible: https://github.com/python/cpython/blob/f62ad4f2c4214fdc05cc4...
comment by orlp · 2022-05-21 · in Python Standard Library changes in recent years -
Sadly it does not call into the hardware implementation: https://github.com/python/cpython/blob/f62ad4f2c4214fdc05cc4...
comment by saagarjha · 2022-05-21 · in Python Standard Library changes in recent years -
…Sam Gross' work: https://docs.google.com/document/d/18CXhDb1ygxg-YXNBJNzfzZsD... The GIL code: https://github.com/python/cpython/blob/main/Python/ceval_gil... Py_INCREF: https://github.com/python/cpython/blob/a4460f2eb8b9db46a9bce...
comment by kortex · 2022-05-18 · in Python 3.11 beta vs. 3.10 benchmark -
The Python source - https://github.com/python/cpython/ - with full commit history back to 1990. The Unix source - https://github.com/dspinellis/unix-history-repo - with quite a number of releases dating back to 1970.
comment by eesmith · 2022-05-18 · in Ask HN: What's the oldest publicly-available repo with different versions? -
…its roots in 1998 or so. You can see how primitive testing was with this example from Python 1.3: https://github.com/python/cpython/blob/v1.3/Lib/test/test_b2... . That's actually one of the most sophisticated ones there. The test_md5…
comment by eesmith · 2022-05-12 · in I'd love a history of Python tooling -
…or thereabouts. [1] 3.7.0 is the first major release following the removal of the config option in https://github.com/python/cpython/issues/75551 .. there's also a 2021 comment about "This has unfortunately turned out to be a blocker on…
comment by fulafel · 2022-05-12 · in Python Language Summit: Python Without the GIL -
…source code links for standard library results. E.g. searching for heapq would also show a link to https://github.com/python/cpython/blob/main/Lib/heapq.py I know these links are already at the very top of most pages in the python…
comment by showmecode · 2022-05-10 · in Show HN: Pythondocs.xyz – Live search for Python documentation -
…After six years of intense bikeshedding, it was finally put in standard "datetime" in 2018. [1] https://github.com/python/cpython/issues/60077
comment by Animats · 2022-05-01 · in Rust from 0 to 80% for JavaScript Developers -
…languages with closed source development). For Python, it looks like everything is on GitHub: https://github.com/python/cpython https://github.com/python/peps It might take some exploring depending on what you are trying to find (over 100k…
comment by thesuperbigfrog · 2022-04-27 · in Ask HN: Best way to find out when features were added to languages? -
Python's main interpreter loop is a single 4k line function. https://github.com/python/cpython/blob/main/Python/ceval.c#L...
comment by rahimiali · 2022-04-03 · in A project with a single 11,000-line code file -
…STORE_FAST 0 (a) 8 STORE_FAST 1 (b) 5 10 LOAD_FAST 0 (a) 12 RETURN_VALUE Implementation of ROT_TWO https://github.com/python/cpython/blob/bc85eb7a4f16e9e2b6fb7...
comment by kmill · 2022-03-24 · in Swapping two Numbers without Temporary Variables -
…a closed connection, which the SQLite C documentation warns against. A couple of searches against https://github.com/python/cpython lead me to this code here: https://github.com/python/cpython/blob/4674fd4e938eb4a29ccd5...
comment by simonw · 2022-03-21 · in Ask HN: Codebases with great, easy to read code? -
…short Python wrapper around binascii. It's only 206 lines, much of which is comments or docstrings: https://github.com/python/cpython/blob/a5b7678a67ac99edd5082... It has three functions: one to encode, one to decode, and one to show usage…
comment by bariumbitmap · 2022-03-18 · in PEP 594 – Removing dead batteries from the standard library -
…[1]. To be honest, I was really surprised how needlessly complex that particular code is. [1] - https://github.com/python/cpython/blob/main/Lib/argparse.py
comment by genmud · 2022-03-18 · in Python finally offloads some batteries -
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 -
…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…
comment by nonameiguess · 2022-03-16 · in In the time Python can perform 1 FLOP, an A100 can chew through 9.75M FLOPS -
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...
comment by _dain_ · 2022-03-08 · in Buffet – An All-inclusive Buffer for C -
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 -
…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? -
> 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…
comment by rfoo · 2022-02-03 · in Competitive Programming with AlphaCode -
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…
comment by js2 · 2022-01-24 · in I accidentally used YAML.parse instead of JSON.parse and it worked -
…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…
comment by jomar · 2022-01-07 · in I found a one-char typo in the docs for Python's typing_extensions library -
…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
comment by atorodius · 2021-12-24 · in Attrs – the Python library everyone needs (2016) -
…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…
comment by postpawl · 2021-12-20 · in Fixing memory leaks in popular Python libraries -
Python's csv imports _csv for core functionality, which is C: https://github.com/python/cpython/blob/main/Modules/_csv.c
comment by __s · 2021-12-16 · in Leveraging SIMD: Splitting CSV Files at 3Gb/S -
…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 -
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 -
…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 -
…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 -
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 -
…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 -
…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...
comment by perth · 2021-11-10 · in Ask HN: How did Python become the lingua franca of ML/AI? -
…-- 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:…
comment by shoo · 2021-11-06 · in In C, how do you know if the dynamic allocation succeeded? -
…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…
comment by __s · 2021-11-03 · in Python interpreter written in rust reaches 10000 commits -
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 -
…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#...
comment by epage · 2021-11-02 · in Sysexits – preferable exit codes for programs -
…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 -
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 -
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