4 ms·
From the top of my head before I get off the bus: Things like proper static modules so that you know what is being called so you can elide lookups at call-time
by bjoli 5y ago
From the top of my head before I get off the bus:
Things like proper static modules so that you know what is being called so you can elide lookups at call-time. That is a pretty big omission, TBH.
For a long time (still?) python had a horribly inefficient value representation in memory. Now, integer tagging is probably no fun to add as an afterthought, but it shouldn't have been an afterthought.
Exception handling is sloooow. And iterators use exceptions to signal that younhave exhausted the collection. Because iterating over a complete collection is exceptional.
I understand the need to keep cpython simple, but some of these things ARE simple and have been well understood since a decade before python 1.0.
- orf 5y agoStatic modules with elided lookups is completely nonsensical in Python. StopIteration is special-cased and has negligible overhead. See here (https://www.python.org/dev/peps/pep-0234/ https://www.python.org/dev/peps/pep-0234/) for why exceptions are used.
- bjoli 5y agoOn the contrary. Static modules would mean static classes with no possibility of changing a class. That would be another pretty nice optimization you could do, making class lookups a lot faster. I am not alone in thinking this would be a good idea. The Instagram folks wrote about it, iirc. That rationale for using an exception is only valid because CPython procedure calls are expensive. A proper optimizing compiler will have a hard time rewriting that implicit try/catch into a goto. I think Dart nailed iterators in this regard: no special values, and a protocol that is transparent to the compiler, which has the benefit of requiring no special cases at all. In the current state of cpython, of course, that falls into the "2 expensive procedure calls that can't be inlined because everything can be mutated at any time" type of a problem.
- omginternets 5y ago>Static modules would mean static classes with no possibility of changing a class. That would be another pretty nice optimization you could do, making class lookups a lot faster. I think the whole point of python is to make everything dynamic. It seems like this trade-off is voluntary, i.e. it is a feature, not a bug.