3 ms·
Pypy is not that much faster than Python and is certainly still much slower than using a C library. Indeed, there's a limit to how fast python can be considerin
by ChrisSD 9y ago
Pypy is not that much faster than Python and is certainly still much slower than using a C library. Indeed, there's a limit to how fast python can be considering how many operations it needs to do for even simple statements (such as summing two integers[0]).
This is the cost of being so extremely dynamic, more so than Javascript and many other scripting languages.
[0] https://jakevdp.github.io/blog/2014/05/09/why-python-is-slow/#Python-Addition https://jakevdp.github.io/blog/2014/05/09/why-python-is-slow...
- pjmlp 9y agoEven after reading that post, I doubt Python can be more dynamic than Lisp or Smalltalk, and yet they are behind the genesis of JIT compilers.
- jerf 9y agoI don't know that it "is", but it certainly can be. In Python there's just too many ways to screw with the meaning of "a.b" at runtime; it could be in the class dict, it could be a property, it could be modified via a couple of methods on the class, it could be screwed with a couple of other ways too IIRC. You have to write some sort of code that either proves these things can't happen, which gets really hard as the program scales up, or code that checks for them happening. Other languages that can be "dynamic" but still have only one or two things to be checked can be much more easily JIT'ed.
- pjmlp 9y agoSmalltalk has a message called becomes, where you literally change the complete representation of an object to something else. You can change code on the fly on the debugger and just do a redo of the failed call. When you change a specific class, or its meta-class, the whole system is automatically updated, reflecting the changes. I can give many more examples.
- pwang 9y agoI believe much similar magic is possible in Python, but you get to implement it on top of the relatively simple interactions between instance dict, class dict, and metaclass. They would not be bullet-proof, and they are not built into the default implementation. But they are very possible.
- smitherfield 9y ago"Everything is an object" is a higher-level abstraction (that is, maps worse to native operations) than "everything is a function" and "everything is a linked list." Also, I don't know much about Lisp, but I was under the impression that Lisp metaprogramming can be entirely or mostly resolved at compile-time, while the same is not true of Python. Smalltalk is even slower than Python.
- scroot 9y agoIn theory one could build a computer that runs Smalltalk at a fast speed.
- joshuamorton 9y agoAnd in reality people have built interpreters that run python at a high speed.
- pjmlp 9y agoI guess we don't have the same understanding of what high speed actually means.
- joshuamorton 9y agoIn the context of the above comment, I'd say that they're about the same. Pypy appears to run between half-as-fast and twice-as-fast as java (hotspot) with a much smaller memory footprint, depending on the benchmark.
- pjmlp 9y agoThat is funny, the language whose JIT research lead to Hotspot, is slower than Python. Since I was using Smalltalk for university projects before Java was a thing, I guess you mean Python wrappers written in C.