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
-
…return. The C tuple packing function cannot return directly from the Python function. Looking at https://github.com/python/cpython/blob/master/Python/ceval.c , here is the code that needs to be executed after the tuple is constructed: case…
comment by tom_mellior · 2020-07-22 · in Data structures and algorithms I actually used while working at tech companies -
…does not mean adding pipes and arguments. This is one important benefit of not using shell. See https://github.com/python/cpython/blob/master/Lib/webbrowser...
comment by Too · 2020-07-14 · in Hacking with environment variables -
…and nowadays, it almost is. This is the only part left that uses it, to create the constructor: https://github.com/python/cpython/blob/master/Lib/collection... Even there it's not strictly necessary. You could accomplish the same thing…
comment by duckerude · 2020-07-06 · in Brython – A Python 3 implementation for client-side web programming -
…as the first operation, not knowing whether it received an iterator or some other kind of iterable. https://github.com/python/cpython/blob/384621c42f9102e31ba2c... If you search for `list` in the CPython code, you'll find many examples of…
comment by xapata · 2020-06-25 · in Specific ways to write better Python (2017) -
If you want to follow along in the Python source code, the relevant file is https://github.com/python/cpython/blob/master/Python/ceval.c . The interpreter is a loop over a big switch statement on the byte codes. Most operations are pretty…
comment by tom_mellior · 2020-06-24 · in The PVM – Python Virtual Machine -
…[2], so aren't such a special case anymore. [1] https://www.python.org/dev/peps/pep-0530/ [2] https://github.com/python/cpython/pull/20370 , https://github.com/python/cpython/pull/20370/files
comment by mkl · 2020-06-24 · in PEP 622 – Structural Pattern Matching -
…of the Python project, called distutils.dist.Distribution which has a function named is_pure(): https://github.com/python/cpython/blob/e42b705188271da108de4... Which makes sure that it doesn't have any known external modules or c…
comment by X-Istence · 2020-06-21 · in Python Wheels Crosses 90% -
…[2]: https://www.programminglogic.com/example-of-client-server-pr... [3]: https://github.com/python/cpython/blob/3.8/Lib/asyncio/unix_...
comment by ben509 · 2020-06-14 · in Async Python is not faster -
…which is ~1500 LOC [2]. I guess parsing CSVs reliably is a reasonably difficult undertaking. [1] https://github.com/python/cpython/blob/3.8/Lib/csv.py [2] https://github.com/python/cpython/blob/4a21e57fe55076c77b0ee...
comment by asadjb · 2020-05-15 · in So you want to write your own CSV code (2014) -
One obvious use case invoked all the time: tracebacks are generated through introspection. https://github.com/python/cpython/blob/3.8/Lib/traceback.py
comment by oefrha · 2020-05-05 · in Python goto implemented with system trace function (2017) -
…). It is Turing complete. See source code and documentation at https://github.com/python/cpython/blob/master/Lib/pickle.py#... https://github.com/python/cpython/blob/master/Lib/pickletool... N.B: "Turing complete" really
comment by bugmen0t · 2020-04-24 · in Accidentally Turing-Complete -
As far as I can see this should be the list of changes: https://github.com/python/cpython/blob/v2.7.18/Misc/NEWS.d/2...
comment by wichert · 2020-04-21 · in Python 2.7.18, the last release of Python 2 -
If you're interested in what actually changed in this update, the release notes are here: https://github.com/python/cpython/blob/2.7/Misc/NEWS.d/2.7.1...
comment by csande17 · 2020-04-20 · in Python 2.7.18, the last release of Python 2 -
They stopped making changes on January 1st 2020 https://github.com/python/cpython/commits/2.7 This is the release of the changes up to that date, since they don't release instantly.
comment by shpx · 2020-04-20 · in Python 2.7.18, the last release of Python 2 -
…implemented in this way. A concrete example would be Python's PyObject which share PyObject_HEAD. https://github.com/python/cpython/blob/master/Include/object...
comment by epr · 2020-04-15 · in Tell HN: C Experts Panel – Ask us anything about C -
…earlier comment I was responding to mentioned only Python, not Go. And Python suppresses SIGPIPE: https://github.com/python/cpython/blob/master/Python/pylifec... , https://github.com/python/cpython/blob/master/Doc/library/si... > Does the…
comment by loeg · 2020-03-22 · in How do Unix pipes work? -
This was definitely not accidental. Here is the commit that introduces `all` and `any`: https://github.com/python/cpython/commit/96229b19181 It includes a test for the empty case: `self.assertEqual(all([]), True)`. They knew what they were…
comment by globular-toast · 2020-03-18 · in The 2,500 year old history of why Python’s all([]) returns True -
…definition. def all(iterable): for element in iterable: if not element: return False return True https://github.com/python/cpython/blob/master/Python/bltinmo...
comment by syphilis2 · 2020-03-18 · in The 2,500 year old history of why Python’s all([]) returns True -
▲ 143
Dictionary union (PEP 584) is mergedstory by whalesalad · 2020-02-25 · 84 comments
-
eval(/exec) is how dataclasses (and namedtuples before them) work: https://github.com/python/cpython/blob/4c1b6a6f4fc46add0097e... . It is a big gun, but sometimes (usually deep within lib code) big guns are the right answer. Don't use…
comment by wrmsr · 2020-02-17 · in Overload functions in Python -
I _think_ this may be the implementation: https://github.com/python/cpython/blob/60ac6ed5579f6666130fc... There are copious notes in there about the implementation and it indicates linked lists are used. EDIT: Blargh, it's here:…
comment by Rapzid · 2020-02-08 · in Python dicts are now ordered -
Don't think so; at least on Windows it uses the optimal QueryPerformanceCounter API. https://github.com/python/cpython/blob/master/Python/pytime....
comment by pjc50 · 2020-01-18 · in Measure code execution time accurately in Python -
It seems to be enabled by default since 2013/Python 3.4: https://bugs.python.org/issue5845 https://github.com/python/cpython/commit/1a6cb30a346ba8812d6... https://docs.python.org/3.4/whatsnew/3.4.html#sys Support already existed in Python…
comment by duckerude · 2020-01-16 · in Autocomplete as an Interface (2015) -
…conditioned on the fd being 31. From that breakpoint I did a Python backtrace (using the tools from https://github.com/python/cpython/blob/master/Misc/gdbinit ) to figure out the Python code that was responsible for the allocation. The…
comment by nneonneo · 2020-01-13 · in Bug #915: Please help -
It's still like that in CPython: https://github.com/python/cpython/blob/master/Lib/tempfile.p... If there's a strong enough case that this is broken (and the KeyboardInterrupt example is a good one), I think we should file a bug about it.…
comment by nneonneo · 2020-01-13 · in Bug #915: Please help -
…- it really shouldn't... My guess is the tempfile is leaking due to the attribute caching here https://github.com/python/cpython/blob/master/Lib/tempfile.p... . But that doesn't really explain why the file is getting closed twice.…
comment by asdfaoeu · 2020-01-13 · in Bug #915: Please help -
…libuv, like Node - is apparently the fastest asyncio event loop. CPython Asyncio C module source: https://github.com/python/cpython/blob/master/Modules/_async... Asyncio docs: https://docs.python.org/3/library/asyncio.html (When things…
comment by westurner · 2019-12-25 · in Ask HN: Is it worth it to learn C in 2020? -
…and cite to a follow up spec addressing a bug in the initial treatment of negative timezones... https://github.com/python/cpython/blob/master/Lib/email/_par...
comment by iudqnolq · 2019-12-17 · in Hacking GitHub's Auth with Unicode's Turkish Dotless 'I' -
…uses of Ellipsis are actually special-cased; it is not a standard part of the abstract syntax. [0] https://github.com/python/cpython/blob/master/Parser/Python....
comment by lidHanteyk · 2019-12-17 · in A tiny Python exception oddity -
…the venv module added in 3.3 gets the job done. And that does default to symlinks for posix. https://github.com/python/cpython/blob/3.8/Lib/venv/__init__...
comment by more-coffee · 2019-12-07 · in Two malicious Python libraries caught stealing SSH and GPG keys -
▲ 10
Python 3.9 Alpha 1 releasedstory by gonational · 2019-11-20 · 3 comments
-
Python uses a String conversion to implement rounding, so why not? :) https://github.com/python/cpython/blob/master/Objects/floato...
comment by soVeryTired · 2019-11-11 · in My Favorite Programming Problem to Teach: Digit Length -
Funny fact: the python round implementation actually uses strings. https://github.com/python/cpython/blob/master/Objects/floato...
comment by pd0wm · 2019-11-11 · in My Favorite Programming Problem to Teach: Digit Length -
Depends on the area of the code you look at, but they can be fairly sparse, yes: https://github.com/python/cpython/blob/master/PC/python_uwp.... I'd say that redis is probably a better example of gold standard clean C code, though, and…
comment by pytester · 2019-11-10 · in Keep your source code SIMPLE -
…it sound like this line of documentation has been in place since the library was first written. https://github.com/python/cpython/commit/52465e1b8bb7af23d64... Edit: Correct commit from 2015 https://github.com/python/cpython/commit/9f3c094e…
comment by sh-run · 2019-10-16 · in Different OSes produced different results for Chemists using Python -
The mail is from 2010 but it was only implemented in 2016, I wonder why. Found the link in https://github.com/python/cpython/blob/master/Objects/dictob... .
comment by lapink · 2019-10-15 · in The idea behind dicts being ordered since python3.6 -
…it strictly more complex. [1]: https://github.com/chucksmash/jsonish/blob/master/jsonish/to... [2]: https://github.com/python/cpython/blob/41c57b335330ff48af098...
comment by chucksmash · 2019-09-29 · in JSON for Modern C++ -
…python algo does not get slow when n is large. The k~n case obviously calls for inverse selection. https://github.com/python/cpython/blob/master/Lib/random.py#...
comment by avip · 2019-09-13 · in Algorithm No One Knows About (2016) -
…derivative works, distribute, and otherwise use Python alone or in any derivative version" (from: https://github.com/python/cpython/blob/2.7/LICENSE ) It you're uptight because the PSF owns and protects the trademark to the name "Python"…
comment by bigiain · 2019-09-09 · in Sunsetting Python 2 -
…able to be characterised as "grabbing it out of the hands of people still using it"??? Here: https://github.com/python/cpython/tree/2.7 Join the other 11.5k people who've forked it on Github, and an unknown number of people who've cloned…
comment by bigiain · 2019-09-09 · in Sunsetting Python 2 -
…to file a bug, but they found out it already exists, just hasn't been merged into the 2.x tree. - https://github.com/python/cpython/commit/46ed90dd014010703c7... - https://github.com/python/cpython/pull/13638 -…
comment by drej · 2019-09-09 · in Sunsetting Python 2 -
…are object pointers, too. CPython just so happens to preallocate a range of small integers[0]. [0]: https://github.com/python/cpython/blob/master/Objects/longob...
comment by hope-striker · 2019-09-05 · in Rust in Large Organizations -
▲ 268
Python rounds float values by converting them to string and then backstory by bishala · 2019-08-28 · 144 comments
-
…a negative value is beyond the scope of python. Python is making use of malloc/free under the hood: https://github.com/python/cpython/blob/master/Objects/obmall... There's some flexibility for wrapping free in different ways in that file,…
comment by CogitoCogito · 2019-08-05 · in Memory Management in Python -
▲ 1
Cpython List Object Implementationstory by davidjnelson · 2019-07-30 · 0 comments
-
…sense. On balance it removes several hundred lines and often makes the code much clearer, e.g. https://github.com/python/cpython/pull/8122/files#diff-78e8e...
comment by orangecat · 2019-07-17 · in What's Coming in Python 3.8 -
[-5, 256]: https://github.com/python/cpython/blob/master/Objects/longob...
comment by saagarjha · 2019-07-10 · in Python consumes a lot of memory – how to reduce the size of objects? -
…) Reading the source of your favorite interpreted programming language can be rewarded, e.g. https://github.com/python/cpython
comment by git-pull · 2019-07-07 · in Ask HN: How do you read and understand an open-source project? -
…For example: `Callback = typing.Callable[[str], Callback]` and `Foo = Union[str, List['Foo']]`. [0] https://github.com/python/cpython/blob/3.8/Lib/typing.py#L15... [1] https://github.com/python/mypy/issues/731 [2]…
comment by neuland · 2019-06-12 · in A Failed Experiment with Python Type Annotations -
▲ 3
Zen of Python (import this) message encrypted with ROT13story by tandav · 2019-06-09 · 0 comments