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
-
…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 -
▲ 2
Ask HN: Blocking os.urandom calls in Python = 3.6story by jbaviat · 2018-11-19 · 4 comments
-
…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 -
▲ 38
How PEP-572 would change the standard librarystory by rbanffy · 2018-07-06 · 65 comments
-
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 -
▲ 1
CPython GIL Implementationstory by marviel · 2017-11-27 · 0 comments
-
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] -
…will be always wrong except in the uncommon case of a sequence of several identical opcodes). [1] https://github.com/python/cpython/blob/ff8ad0a576c6cf375e682...
comment by vilda · 2017-10-04 · in Are Jump Tables Always Fastest? -
…you can + on BUT strings [0], this is to avoid quadratic behavior with string concatenation. [0] https://github.com/python/cpython/blob/5837d0418f47933b2e3c1...
comment by Franciscouzo · 2017-09-30 · in Haskell People -
…[2] https://kbknapp.github.io/clap-rs/unicode_segmentation/index... [3] https://github.com/python/cpython/blob/49b2734bf12dc1cda80fd...
comment by masklinn · 2017-09-07 · in How Python does Unicode -
…examples you gave are examples of that good use. The time.localtime() used to return a tuple. See https://github.com/python/cpython/blob/770e4042db8a1c277b5d9... . The change to StructTimeType is an example of how to do that sort of…
comment by eesmith · 2017-08-30 · in Reducing Python's startup time -
…deeply first. For the specific case under discussion, ncoghlan added cache_info() on 30 Nov 2010 - https://github.com/python/cpython/commit/234515afe594e5f9ca1... Previously, "Performance statistics stored in f.cache_hits and…
comment by eesmith · 2017-08-30 · in Reducing Python's startup time -
https://github.com/python/cpython/blob/v3.6.2/Lib/collection...
comment by jwilk · 2017-08-30 · in Reducing Python's startup time -
…git archaeology. Here are relevant commits and bug reports: * Initial commit with -1...99 cached: https://github.com/python/cpython/commit/842d2ccdcd540399501... * Cache more negative numbers, -5...99:…
comment by jwilk · 2017-08-24 · in Weird Python Integers -
…the GIL for the time of the compression (though it locks the compressor object simultaneously): https://github.com/python/cpython/blob/d4b93e21c2664d6a78e06...
comment by akx · 2017-08-14 · in Let's Remove the Global Interpreter Lock -
Argparse's source is possibly the most difficult lib to grow from the stdlib. https://github.com/python/cpython/blob/master/Lib/argparse.p... For me, it is not debugable. I wanted to propose and start a reference implementation for…
comment by yes_or_gnome · 2017-07-28 · in Python Entry Points Explained -
https://github.com/python/cpython/blob/5d75f441ef0a3cfe7af0d...
comment by andars · 2017-07-22 · in Converting floats to strings -
…but it also doesn't appear to limit itself to C89, see for instance this random file I opened: https://github.com/python/cpython/blob/master/Python/future.... You can see that `const char *feature` is declared in the middle of some code.…
comment by simias · 2017-07-13 · in Toward Go 2