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
-
…what signal was caught and executes the signal handler, before trying to do the remaining write: https://github.com/python/cpython/blob/5f7aba938cf5007b6f954... Here's even a test for it: https://github.com/python/cpython/blob/5f7aba938cf50…
comment by skitter · 2023-10-16 · in Should you be scared of Unix signals? (2016) -
…[0] just as well as in subinterpreters (and currently isn't implemented in either one). [0] https://github.com/python/cpython/issues/89467
comment by ptx · 2023-10-02 · in Python 3.12 -
…then no, it doesn't. None of the variables in the outer scope are captured in the class instance. https://github.com/python/cpython/blob/main/Lib/functools.py... Here's a simplified version of that code that demonstrates the pattern. class…
comment by Spivak · 2023-09-20 · in Fixing for loops in Go 1.22 -
…urllib library recently had a CVE for failing to strip whitespace from the scheme and domain. https://github.com/python/cpython/issues/102153
comment by richbell · 2023-09-07 · in When URL parsers disagree -
…off made for a slightly more efficient implementation. The initial commit of these two functions - https://github.com/python/cpython/commit/96229b191814556622b... - is exactly as Guido’s suggestion, but does include a test case for empty…
comment by rickboyce · 2023-08-25 · in Why does all() return True if the iterable is empty? -
…3 >>> (x % 1).limit_denominator(9999) Fraction(375, 1757) The mediant-based implementation is at https://github.com/python/cpython/blob/607f18c89456cdc9064e2...
comment by eesmith · 2023-08-15 · in Decimal to fraction -
…will also do something like that, specifically it snips out repeated lines in self-recursive calls: https://github.com/python/cpython/issues/71010 >>> a() Traceback (most recent call last): File "<stdin>", line 1, in <module> File…
comment by masklinn · 2023-08-08 · in Go 1.21 Released -
…global functions (I overlooked it at first). The library makes this on the fly with a nice trick: https://github.com/python/cpython/blob/f978a79130133de1cf264... they make a global function for each of methods of the turtle class by means…
comment by MichaelMoser123 · 2023-08-05 · in Ways to teach kids to code (2016) -
…on any Python 3.8 or greater running on MacOS, enforced via "platform == darwin" runtime check: https://github.com/python/cpython/pull/13626/files#diff-6836... You can check the default process-start method of your Python's multiprocessing…
comment by zbentley · 2023-07-31 · in What's up, Python? The GIL removed, a new compiler, optparse deprecated -
…issue below, this can occasionally cause issues, but in my experience it does so rarely if ever. 1. https://github.com/python/cpython/issues/77906 2. https://docs.python.org/3/library/multiprocessing.html#conte...
comment by zbentley · 2023-07-31 · in What's up, Python? The GIL removed, a new compiler, optparse deprecated -
…> Can we get an in-python fork() mechanic ... please? You probably want Multiple Subinterpreters: https://github.com/python/cpython/issues/84692
comment by pritambaral · 2023-07-29 · in Intent to approve PEP 703: making the GIL optional -
…trace from quite a way back when e.g. the first commit in which I can find the len() builtin ( https://github.com/python/cpython/commit/c636014c430620325f8... ) also has calls to file.read and list.append, and the first python-level…
comment by masklinn · 2023-07-25 · in Python: Overlooked core functionalities -
…s://github.com/dabeaz-course/practical-python/blob/maste... [3] https://peps.python.org/pep-0617/ [4] https://github.com/python/cpython/blob/3.8/Grammar/Grammar [5] https://github.com/python/cpython/blob/1663f8ba8405fefc82f74... [6]…
comment by jamesdutc · 2023-07-19 · in Advanced Python Mastery -
…the interpreter code: 1. PyList_SetItem calls Py_XSETREF(dst, src) where dst is the list position: https://github.com/python/cpython/blob/ee46cb6aa959d891b0a48... 2. Py_XSETREF calls Py_XDECREF on the old item:…
comment by js2 · 2023-07-09 · in If PEP 703 is accepted, Meta can commit three engineer-years to no-GIL CPython -
…for CPython and Postgre - which lines of code would you need to touch to achieve these purposes? https://github.com/python/cpython In json module: add parameter to load() and loads() that when True only allows spaces as whitespace…
comment by SonOfLilit · 2023-07-04 · in Leveling up in job interviews for software engineers (2022) -
Oh, and multi-line statements will be supported from Python 3.13 ( https://github.com/python/cpython/issues/103124 )
comment by johnnymellor · 2023-06-29 · in CLI tools hidden in the Python standard library -
…or probably a PEP to add new functionality to exec. I'll file a bug against Python soon. [1]: https://github.com/python/cpython/blob/25a64fd28aaaaf2d21fae... [2]: https://github.com/python/cpython/blob/25a64fd28aaaaf2d21fae...
comment by johnnymellor · 2023-06-29 · in CLI tools hidden in the Python standard library -
…because most operating systems have sqlite3 and python3, but are missing the SQLite CLI. [0]: https://github.com/python/cpython/blob/3fb7c608e5764559a718c... [1]: https://docs.python.org/3.12/library/sqlite3.html#command-li...
comment by polyrand · 2023-06-29 · in CLI tools hidden in the Python standard library -
…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 -
▲ 2
CPython Timsort Implementation Notesstory by juliusgeo · 2023-05-05 · 1 comment
-
…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? -
▲ 2
Python Might Remove Math.pi?story by extasia · 2023-04-01 · 5 comments
-
…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 -
▲ 2
Cpython/Lib/Antigravity.pystory by spenczar5 · 2023-02-22 · 0 comments
-
…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