4 ms·
cPython does alot of work for just about any piece of code. Just a small handful of things: 1. everything's a hash (object data, variable lookup, etc). jmoiron
by shanemhansen 12y ago
cPython does alot of work for just about any piece of code. Just a small handful of things:
1. everything's a hash (object data, variable lookup, etc). jmoiron wrote a great article on the topic http://jmoiron.net/blog/whats-going-on/ http://jmoiron.net/blog/whats-going-on/
2. refcounting introduces overhead for every variable access
3. loops are making all kinds of function calls to __iter__, next(), and catching StopIteration, which makes it hard to have a tight loop.
4. There's the GIL, builtin locking isn't great.
5. lots of indirection (lack of value types)