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
-
…with magnitudes of inputs etc all over the dang place. Like, seriously, everywhere. Take a look: https://github.com/python/cpython/blob/main/Objects/longobje... I certainly hope for at least some of that code the compiler ends up making…
comment by tsukikage · 2023-06-19 · in The legend of “x86 CPUs decode instructions into RISC form internally” (2020) -
…I just went for CPython's implementation of `list`. It took me less than 2 minutes to find it: https://github.com/python/cpython/blob/main/Objects/listobje... . If you're curious, CPython essentially grows its dynamic array by ⅛ (12.5%)…
comment by qsantos · 2023-06-18 · in Python Dict – An Explorable Explanation -
…module [1] even though it was mentioned as part of the rationale in PEP 574 [2]. [1] https://github.com/python/cpython/issues/89467 [2] https://peps.python.org/pep-0574/
comment by ptx · 2023-06-16 · in Our Plan for Python 3.13 -
…I understand is in fact originally a Django creation too (or at least its first popularising use https://github.com/python/cpython/issues/65344 ).
comment by evrimoztamur · 2023-06-10 · in Django Views – The Right Way -
Since 2001, it seems: https://github.com/python/cpython/blob/3.11/Lib/doctest.py#L...
comment by bradbeattie · 2023-06-10 · in Executable Examples in Go -
…- I haven't yet used non-ASCII in my code! Then you may enjoy this april fool's python issue I made https://github.com/python/cpython/issues/103172 Yeah, I like using utf-8 chars for mathematical symbols, it makes my brain hurt a little…
comment by extasia · 2023-06-01 · in Show HN: Word2vec Algorithm in ~100sloc with NumPy -
…are emitted, and paw through the main evaluation loop [1]; or take a guided walkthrough at [2]. [1] https://github.com/python/cpython/blob/v3.6.14/Python/ceval.... (note this is an old version, you can change that in the url) [2]…
comment by klyrs · 2023-05-11 · in Faster CPython at PyCon, part one -
Looks like cpython does the same thing if for small n. https://github.com/python/cpython/blob/a9c6e0618f26270e2591b...
comment by Atlas22 · 2023-05-09 · in Codon: Python Compiler -
…and put it on the stack. More specifically, we can look at the implementation of "LOAD_FAST" at https://github.com/python/cpython/blob/main/Python/generated... (which has is derived from https://github.com/python/cpython/blob/main/Python/by…
comment by eesmith · 2023-04-10 · in Ask HN: How does the return statement of a function work? -
…since the antigravity module doesn't have a fly attribute, and it "does its thing" on import. https://github.com/python/cpython/blob/main/Lib/antigravity....
comment by wodenokoto · 2023-03-03 · in Why Python keeps growing, explained -
…that post, and it's what other languages use in similar situations (e.g. tuples in Python and C#): https://github.com/python/cpython/blob/71db5dbcd714b2e1297c4...
comment by int_19h · 2023-03-02 · in Effortless Performance Improvements in C++: std:unordered_map -
…was, I guess, a “big-J” problem instead of this “small-j” problem, dealing with non-ASCII letters: https://github.com/python/cpython/issues/80730
comment by dragonwriter · 2023-03-01 · in Python .capitialize oddness a.k.a. little j issue -
…kind of bytecode, who knows. The standard cpython implementation is much more complex, though: https://github.com/python/cpython/blob/main/Python/bltinmodu... Concatenating zip()s is an unnecessarily complex solution, both in terms of…
comment by jeroenhd · 2023-02-27 · in Zig's multi-sequence for loops -
…REPL is implemented[1] [0]: https://docs.python.org/3/library/code.html#code.Interactive... [1]: https://github.com/python/cpython/blob/02d9f1504beebd98dea80...
comment by polyrand · 2023-02-21 · in Show HN: Replbuilder, quickly build a Python REPL CLI prompt -
…Because not eveyone uses an apt-based package manager. Python runs on quite a few platforms: https://github.com/python/cpython/blob/main/Lib/platform.py Apt is not the package manager for most of those platforms. Thus an operating system…
comment by thesuperbigfrog · 2023-02-19 · in Ask HN: Is there a reason every language comes with it's own package manager? -
…money or context, ~3yrs ago. 1. https://authors.library.caltech.edu/5456/1/hrst.mit.edu/hrs/... 2. https://github.com/python/cpython/blob/v3.11.1/Lib/logging/h... 3. https://www.komu.engineer/blogs/09/log-without-losing-contex...
comment by komuW · 2023-02-13 · in Clog: Making a homegrown ClickHouse log for $20 a month -
…can be changed without breaking backwards compatibility (current GC behavior is not deterministic): https://github.com/python/cpython/issues/91887 Latest reply from GvR is invoking Chesterton's Fence. Here's to hoping the devs can quickly…
comment by terom · 2023-02-13 · in A Heisenbug lurking in async Python -
…`create_task()` is a little older, but also only November 2021, so during 3.11 development...? [1] https://github.com/python/cpython/commit/c750adbe6990ee8239b...
comment by terom · 2023-02-13 · in A Heisenbug lurking in async Python -
…was only added in September 2022 [1], so no wonder this comes as a surprise to many! [1] https://github.com/python/cpython/commit/6281affee6423296893...
comment by mhils · 2023-02-11 · in A Heisenbug lurking in async Python -
…in Python? Of course. With dataclasses that's what Python itself does; that's a pure Python module: https://github.com/python/cpython/blob/3.11/Lib/dataclasses.... For MutableMapping, Python currently implements it as a C class for speed,…
comment by pdonis · 2023-02-02 · in Python's “disappointing” superpowers -
…parametrized context, which is a trivial patch, and it has been just sitting there for 10 years: https://github.com/python/cpython/issues/53032 Adding code to import/export BID/DPD formats, while maybe not as trivial, seems still…
comment by zokier · 2023-01-13 · in Examples of floating point problems -
…is IEEE 754 (well, based on the older standard, which has now been absorbed into IEEE 754): https://github.com/python/cpython/blob/main/Lib/_pydecimal.p... Cool, didn't know that gcc had built-in support. But is it really as incomplete as…
comment by jordigh · 2023-01-13 · in Examples of floating point problems -
The same bug, but with more discussion can be found here: https://github.com/python/cpython/issues/100762 Apparently the problem is not with all(), but Generator creation
comment by isaacfrond · 2023-01-11 · in Performance is 30% worse on Python 3.11.1 (vs Python 3.10.9) when using all() -
Here’s the relevant source: https://github.com/python/cpython/blob/8dd2766d99f8f51ad62dc... I believe you should just be able to replace the library name with an absolute path to the library, and remove the need for the lookup at all?
comment by orf · 2023-01-11 · in Surprising Consequences of macOS’s Environment Variable Sanitization -
…with this approach was ECMAScript 2009 (5th ed.) with `use strict` and Python 3 predated it. [1] https://github.com/python/cpython/tree/main/Lib/lib2to3
comment by lifthrasiir · 2023-01-03 · in Python 2 removed from Debian -
…of the Python standard library is written in Python and a good way to see idiomatic Python code. https://github.com/python/cpython/tree/main/Lib
comment by qbasic_forever · 2023-01-01 · in Ask HN: What are the best open source TypeScript projects I can learn from? -
…standard library using exec() to create the `__init__` and other methods that go on your dataclass: https://github.com/python/cpython/blob/main/Lib/dataclasses.... Here's Pydantic using it for a jupyter notebook check:…
comment by zzzeek · 2022-12-23 · in Python malware starting to employ anti-debug techniques -
…I cannot touch anything without finding a bug or at least a suspiciously insectoid lifeform.) [1] https://github.com/python/cpython/blob/7e3f09cad9b783d8968aa...
comment by mananaysiempre · 2022-11-22 · in Always use [closed, open) intervals -
It's because cpython shortcuts through identity: https://github.com/python/cpython/blob/main/Objects/object.c... /* Quick result when objects are the same. Guarantees that identity implies equality. */ if (v == w) { if (op == Py_EQ) return…
comment by masklinn · 2022-11-19 · in Go 1.21 may have a clear(x) builtin -
Just copy out cgi.py and use it as a module. https://github.com/python/cpython/blob/3.11/Lib/cgi.py
comment by sigzero · 2022-11-16 · in Python 3.12.0 is to remove long-deprecated items -
…you can then import. Even if they don’t, from a cursory view, it seems it’s a pure python library ( https://github.com/python/cpython/blob/main/Lib/telnetlib.py ). If so, can’t you copy the current code into your project? You would take on…
comment by Someone · 2022-11-16 · in Python 3.12.0 is to remove long-deprecated items -
…implementation in the python stdlib https://docs.python.org/3/library/difflib.html#difflib.Seque... https://github.com/python/cpython/blob/main/Lib/difflib.py
comment by _ZeD_ · 2022-11-03 · in Visualizing Diffs: The Myers difference algorithm (2020) -
…want to await several tasks at once, so I am not sure this changes much for exception handling. * https://github.com/python/cpython/issues/90908 ** https://docs.python.org/3.11/library/asyncio-task.html#task-...
comment by nicoco · 2022-10-25 · in Python 3.11.0 final -
…This is misleading... you can use asyncio.gather which does this internally [0]. [0]: https://github.com/python/cpython/blob/main/Lib/asyncio/task...
comment by throwway2332 · 2022-10-22 · in Python and Async Simplified (2018) -
…middle (via an iterator) in O(1), so it's not a complete replacement for doubly-linked lists. [1]: https://github.com/python/cpython/blob/a4ac14faa5c2be433738d...
comment by hddqsb · 2022-09-24 · in Algorithms and data structures implemented in many programming languages -
…thread in the same interpreter though, so I still don't understand robertlagrant's question. [1]: https://github.com/python/cpython/blob/4b81139aac3fa11779f6e...
comment by remram · 2022-09-21 · in Faster CPython 3.12 Plan -
"the slow-but-simple implementation in module dbm.dumb will be used" No kidding. https://github.com/python/cpython/blob/main/Lib/dbm/dumb.py It uses a text file to store keys and pointers into a binary file for values. It works .. most of…
comment by banana_giraffe · 2022-09-15 · in TIL–Python has a built-in persistent key-value store (2018) -
FWIW, it was added in 1992. https://github.com/python/cpython/commit/dd9ed839d6958f73704... with gdbm added in 1994. https://github.com/python/cpython/commit/4b4c664d2e93279c8d7... .
comment by eesmith · 2022-09-15 · in TIL–Python has a built-in persistent key-value store (2018) -
…what you want and then try again if it’s outside your range. And indeed this is how Python does it https://github.com/python/cpython/blob/e37ac5fbb6de593521cf2... https://github.com/python/cpython/blob/e37ac5fbb6de593521cf2...
comment by Spivak · 2022-09-15 · in I figured out how to get GitHub Copilot to run in the terminal -
The ValueError in "2*2*2*2*2" is a recent change to limit denial of service attacks. See https://github.com/python/cpython/issues/95778 . In short, the value you want has 19729 digits in base-10, the conversion from the internal base-30…
comment by eesmith · 2022-09-12 · in Ask HN: Why hasn't the deep learning community embraced Julia yet? -
…algorithm exists to do otherwise." isn't true. This comment in particular is worth reading: https://github.com/python/cpython/issues/95778#issue-1331477...
comment by josephcsible · 2022-09-08 · in Int/str conversions broken in latest Python bugfix releases in all versions -
…this or done the math rigorously :) edit: this is also buried in the issue. There’s also: https://github.com/python/cpython/issues/90716 I don’t get it.
comment by amluto · 2022-09-07 · in Prevent DoS by large int-str conversions -
…there is no algorithm for this that isn't quadratic. Update: I may have understood incorrectly, see https://github.com/python/cpython/issues/90716
comment by simonw · 2022-09-07 · in Prevent DoS by large int-str conversions -
…a lot of discussion afterwards--but because the discussion was on-topic, the issue was not locked. https://github.com/python/cpython/issues/90716
comment by klodolph · 2022-09-07 · in Prevent DoS by large int-str conversions -
It looks like there is some discussion of the algorithmic options at https://github.com/python/cpython/issues/95778 https://github.com/python/cpython/issues/90716 Is there something bad going on with Python's internal representation of big…
comment by schoen · 2022-09-07 · in Prevent DoS by large int-str conversions -
…numpy test suite passes before https://github.com/numpy/numpy/issues/22098 is widely available. https://github.com/python/cpython/blob/511ca9452033ef95bc7d7...
comment by js2 · 2022-09-07 · in Prevent DoS by large int-str conversions -
https://github.com/python/cpython/issues/95778 has more information.
comment by jwilk · 2022-09-07 · in Prevent DoS by large int-str conversions -
…its native permutations function. The C source is, as always, extremely easy to understand: https://github.com/python/cpython/blob/main/Modules/itertool...
comment by qsort · 2022-08-23 · in Permutation Generation Methods [pdf] -
I totally missed that! Thanks for the additional detail. This issue appears to have been fixed: https://github.com/python/cpython/issues/75820
comment by benji-york · 2022-08-16 · in Ask HN: Can I see your scripts? -
…before Am I missing a particular point the article is making, or did the author overlook this? [0]: https://github.com/python/cpython/blob/main/Lib/_py_abc.py
comment by w-m · 2022-08-02 · in Crimes with Python's pattern matching