Writing an emulator in python - implementation questions (for performance)

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Thu Nov 12 22:00:16 EST 2009


On Fri, 13 Nov 2009 15:29:03 +1300, greg wrote:

> Generally, I think you're going to have quite a battle on your hands to
> get a pure Python implementation to run as fast as a real Z80, if it's
> even possible at all. And if you do succeed, the code will be pretty
> awful (due to things such as not being able to use named constants).

I don't know about that... 

Python on a 2GHz processor (which is more or less entry-level for desktop 
PCs these days), emulating something which used to run at 2.5MHz? Even if 
the Python code does 1000 times more work, the modern processor is nearly 
1000 times faster, so your Python code won't be much slower than the 
first generation Z80.

The latest Z80 processors operate at 50MHz. That still gives you a factor 
of 40 to work with. Write your Python carefully, optimizing only the bits 
that *need* optimizing, and perhaps using a few C extensions or Psyco, 
and I think you have a good chance of being close enough to the speed of 
a real Z80.



-- 
Steven



More information about the Python-list mailing list