Stefan Behnel skrev: > Good luck. I don't mean to discourage you, but this is a pretty ambitious > goal. >
Python's VM is slow, indeed. It uses a stack-based VM instead of registers; it is implemented in the worst possible way, as code and data form a three of hash tables; it has reference counting instead of garbage collection (produces high cache traffic); it has no JIT compilation. It's doomed to be slow. Many implementations of Common Lisp and Scheme can compete with C (e.g. SBCL, CMUCL, Allegro, Clozure, Ikarus). None of the billion dollar investment that was made into making Lisp fast (during the AI hype 20-30 years ago) has made it into Python. There were even hardware processors (aka 'Lisp machines') that could run Lisp natively. We can sometimes read on Python lists that Lisp's performance comes from optional static typic. That is not the whole story. For example, enourmous efforsts were made for making memory mangement efficient (cons is very effcient, lists are transformed to contiguous arrays internally, tail-recursion is inlined, etc). Lot of this technology is now forgotten, as those who worked on it are retired or has lost interest. Python's memory management (reference counts and malloc/free) is the least efficient ever invented by man. Nothing is stored contiguously (a list of int is not a buffer of int, but an array of pointers). And what data traffic does it take to keep refcounts synchronized in the cache of multiple processors? It's almost a wonder that the computer does not burst into flames. LuaJIT is one or two orders of magnitude faster than Python. It is not just JIT and a proper GC that gives it a performance boost, it also uses a register-based VM (like Parrot and Dalvik). Lua is a dynamic language very similar to Python. There is nothing in the Python language that keeps it from performing like Lua. StrongTalk VM for Smalltalk performs close to C. Smalltalk is also a dynamic language like Python. Sun actually purchased StrongTalk to use the VM for Java -- it is Java's Hotspot JIT compiler. Many claim that Java's performance comes from static typing, but the VM was actually designed for a dynamic language. We all know how Java performes compared to Python, or even compared to C. Why the discrepancy when the VM was designed for Smalltalk? One thing is that much of the experience from boosting Lisp actually made it into StrongTalk, unlike CPython. Reinventing the wheel is not a good thing, as it implies discaring modern tiers. It's not rocket science to make a fast Python. We can make a compiler that runs Python on any of the VMs above (e.g. Android's Dalvik engine or Lua JIT). A Python front-end for LuaJIT would be nearly 100 times faster than the current CPython, with very little investment. It's just that nobody has bothered... However: The main strength of Python is the magnitude of extension libraries available. A completely new Python will be nearly useless on its own. That's the big discouragement. And it is easier to write some C++ or Cython than fixing CPython. Sturla _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
