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
-
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 -
…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 -
…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 -
…surprised by the number of gotos in the Python runtime. The link in the article was down so here: https://github.com/python/cpython/search?q=goto There's a lot of "goto exit" which is obviously a CPython runtime convention - fair enough.…
comment by ridiculous_fish · 2019-05-23 · in Goto and the folly of dogma (2018) -
Especially when you start looking at the code for some of these https://github.com/python/cpython/blob/master/Lib/imghdr.py
comment by ehsankia · 2019-05-22 · in PEP 594 – Removing dead batteries from Python's standard library -
…with a type annotation". (I highlighted the relevant line of the grammar for you in the link.) [0] https://github.com/python/cpython/blob/master/Grammar/Gramma...
comment by DonaldPShimoda · 2019-05-15 · in Things to use in Python 3 -
https://github.com/python/cpython/search?utf8=%E2%9C%93&q=kl...
comment by qwsxyh · 2019-04-19 · in Interface Dispatch (2018) -
…docstrings. CPython's compilation pipeline just has a fairly straightforward peephole optimiser: https://github.com/python/cpython/blob/master/Python/peephol...
comment by masklinn · 2019-02-25 · in The CPython Bytecode Compiler Is Dumb -
…in Parser/tokenizer.c[1]. [0]: https://docs.python.org/3/reference/lexical_analysis.html#in... [1]: https://github.com/python/cpython/blob/master/Parser/tokeniz...
comment by kbirkeland · 2019-02-23 · in Full Python 3 Grammar Specification -
…in stdlib https://bugs.python.org/issue35582 . namedtuple attr access is also now 1.7x faster https://github.com/python/cpython/pull/10495 Other performance improvments : https://github.com/python/cpython/pulls?q=is%3Apr+sort%3Aupd...
comment by xtreak29 · 2019-02-04 · in Python 3.8.0a1 is now available for testing -
…own simplified instruction set. For an example instruction set, check out Python's header file at https://github.com/python/cpython/blob/master/Include/opcode...
comment by ryanmccullagh · 2019-01-25 · in Ask HN: How to learn to write a compiler and interpreter? -
itemgetter and attrgetter are compiled C functions called by cpython https://github.com/python/cpython/blob/master/Modules/_opera...
comment by nszceta · 2019-01-01 · in The fate of reduce() in Python 3000 (2005) -
…a contiguous segment of memory of python object references? Yep, it is an array of pointers: https://github.com/python/cpython/blob/3.7/Include/listobjec... > And when the list needs to be resized and doubles itself, it's just doubling the…
comment by eatitraw · 2018-12-25 · in Show HN: Inside Python Dict – an explorable explanation -
…placing a comma-separated list of expressions in square brackets" CPython implementation is here: https://github.com/python/cpython/blob/e42b705188271da108de4... If I'm talking about arrays with someone else, I would expect us to be…
comment by joatmon-snoo · 2018-12-25 · in Show HN: Inside Python Dict – an explorable explanation -
…using constant offsets from the stack pointer. Here is the code for the normal call fast path: https://github.com/python/cpython/blob/62be74290aca26d16f3f5... f = _PyFrame_New_NoTrack(tstate, co, globals, NULL); if (f == NULL) { return…
comment by tom_mellior · 2018-12-19 · in Reasons Python Sucks -
….pth files??!?! Ever been curious how sys.path gets populated at startup? Gaze into the darkness: https://github.com/python/cpython/blob/master/PC/getpathp.c And to anyone saying "Just use a virtualenv": that is so, so not an answer to…
comment by sebastos · 2018-12-18 · in Reasons Python Sucks -
It's "of", rather than "in"... this is probably the Python one mentioned: https://github.com/python/cpython/blob/d7538dd5e3e04a8db22e1...
comment by tom_ · 2018-12-14 · in Write Your Own Virtual Machine -
…is not automatically generated. But I don't know enough C to say for sure, maybe someone else can. https://github.com/python/cpython/blob/9dfa0fe587eae3626ffc9...
comment by dec0dedab0de · 2018-10-11 · in Asterisks in Python -
…bytecode contained in PyCodeObjects. This layering is even visible in the Python source itself ( https://github.com/python/cpython/tree/v3.7.0 ) - the first three things live under ./Objects in the source tree, and the parser and the…
comment by int_19h · 2018-09-22 · in Inside cpyext: Why emulating CPython C API is so Hard -
…PyNumber_Add(left, right) Line 1495 is PyNumber_InPlaceAdd(left, right) Those go to: PyNumber_Add https://github.com/python/cpython/blob/874809ea389e6434787e7... PyNumber_InPlaceAdd https://github.com/python/cpython/blob/874809ea389e6434787…
comment by hyperpape · 2018-09-06 · in When optimising code, never guess, always measure -
…want to test your theory, you can look at the implementation of those opcodes. Here's INPLACE_ADD: https://github.com/python/cpython/blob/874809ea389e6434787e7... And here's BINARY_ADD: https://github.com/python/cpython/blob/874809ea389e643…
comment by ubernostrum · 2018-09-06 · in When optimising code, never guess, always measure -
…difference now, does it? Proof: Process Pool worker, returning the result by using `outqueue.put()` https://github.com/python/cpython/blob/86b89916d1b0a26c1e77f... multiprocessing Queue, initializing a Pipe…
comment by devxpy · 2018-08-25 · in Parallel Programming with Python -
actually, by using Python you explicitly agree that PSF doesn't owe you anything :) https://github.com/python/cpython/blob/master/LICENSE 4. PSF is making Python available to Licensee on an "AS IS" basis. PSF MAKES NO REPRESENTATIONS OR…
comment by xj9 · 2018-07-19 · in Python post-Guido -
I was going to say - its application in this while loop is really nice I think: https://github.com/python/cpython/pull/8122/files#diff-0ad86...
comment by 2T1Qka0rEiPr · 2018-07-06 · in How PEP-572 would change the standard library -
Python is using Git these days: https://github.com/python/cpython/blob/master/Objects/listob...
comment by jwilk · 2018-07-02 · in Timsort is a sorting algorithm that is efficient for real-world data -
…code, both `extract` and `extractall` call `_extract_member` which sanitizes the file paths. See https://github.com/python/cpython/blob/3.6/Lib/zipfile.py
comment by ishi · 2018-06-05 · in Zip Slip Vulnerability -
…some group, somewhere will champion 2.7. And maybe in ~2030 we'll still see active support. [1] https://github.com/python/cpython/tree/2.7
comment by wyldfire · 2018-05-15 · in Guide to Data Classes in Python 3.7 -
Should be https://github.com/python/cpython/blob/2.7/Misc/NEWS.d/2.7.1... , I think.
comment by eesmith · 2018-05-01 · in Python 2.7.15 release -
https://github.com/python/cpython/blob/2.7/Misc/NEWS.d/2.7.1...
comment by frewsxcv · 2018-05-01 · in Python 2.7.15 release -
…full of macros and gotos, not to mention being 5000 lines long. The interpreter loop starts here: https://github.com/python/cpython/blob/master/Python/ceval.c... So I appreciate seeing the algorithm laid out in Python. In particular it…
comment by chubot · 2018-04-09 · in A Python Interpreter Written in Python (2016) -
…injection style is pretty much equivalent to functional programming. Python is described with ASDL: https://github.com/python/cpython/blob/master/Parser/Python.... ASDL has some relation to "Stanford University Intermediate Format", which…
comment by chubot · 2018-03-16 · in What can we learn from how compilers are designed? -
…of Free Software licensing work. You are absolutely able to go clone their git repo right now ( https://github.com/python/cpython ) and work on it as your own. You can create updates, backport fixes, etc. You can maintain that well after…
comment by briffle · 2018-03-06 · in Google's Python Class -
Better to use the method demonstrated in functools' lru_cache: https://github.com/python/cpython/blob/3.6/Lib/functools.py#...
comment by xapata · 2018-02-27 · in Abusing Python exceptions to turn a recursive function iterative -
…Python. At some point I somehow noticed that he wrote the Python profiler (see the name at the top https://github.com/python/cpython/blob/2.7/Lib/profile.py ). When I asked him about it he made some comment about how he didn't really know…
comment by evmar · 2018-02-16 · in The Jim Roskind C/C++ Grammar -
…lot simpler. Here is the corresponding code (look above for the definition of the GETLOCAL macro): https://github.com/python/cpython/blob/fc1ce810f1da593648b4d... So your code should be more like: locals[a_idx] =…
comment by tom_mellior · 2018-02-07 · in Python’s Weak Performance Matters -
It's interesting for sure, and I'd like to see where it goes, but right now there isn't much to it: https://github.com/python/cpython/blob/3.6/Lib/secrets.py
comment by orf · 2018-02-05 · in Migrating to Python 3 with pleasure -
Try building one yourself ;-) https://github.com/python/cpython/releases/tag/v1.0.1
comment by ojii · 2018-01-27 · in Python 1.0.0 is out (1994) -
Presumably the way to do it would be to add the individual encodings as modules in https://github.com/python/cpython/tree/master/Lib/encodings so the risk of stagnation would be low. I guess the bigger issue would be bikeshedding the names…
comment by maxerickson · 2018-01-09 · in Ftfy – fix Unicode that's broken in various ways -
One thing that was really educational for me was reading how CPython implemented their object system. https://github.com/python/cpython/blob/master/Include/object... Basically objects are structs that all share the same header which…
comment by wybiral · 2017-10-20 · in Object oriented programming with ANSI-C (1993) [pdf]