Concerns about performance w/Python, Pysco on Pentiums

Peter Hansen peter at
Thu Mar 6 03:56:56 CET 2003

phil hunt wrote:
> On Wed, 05 Mar 2003 09:50:27 -0500, Peter Hansen <peter at> wrote:
> >
> >At the moment, it's actually "fast enough", so this isn't an
> >urgent concern.  
> I'm sure the thought of re-coding it in C/C++ has occurred to you.

That thought should be considered by anyone using Python and concerned
about performance, of course.  Not that recoding most of it would
be of interest, but the core portions could certainly be done that way.
As I said, it's fast enough for now.  I'd guess that we could use it
effectively for a year or so, and flesh out all the features before 
we seriously consider that step.  C is so much less malleable than Python.

> Writing a machine code emulator isn't something I'd
> consider Python to be the natural choice for. And I doubt if the C
> code would be much (if any) more complex.

You're probably quite right about the complexity... the relevant functions
are three or four lines apiece and quite simple, *especially* for a
language that understands bit-banging like C does.  (That's part of 
why I was surprised to see practically no speedup with Pysco.  Maybe
it's just not targetted for that kind of code.)

As for the "natural choice", we think along different lines.  For
me, Python is clearly the natural choice for something that inherently
needs to be interfaced with a test framework, and which needs a wide
variety of complex components (the special registers, for example,
and custom hardware used in our products) simulated as well.  I 
would consider C much later, but initially it definitely should be
Python, until the code stops or greatly slows its evolution.
An "emulator" in the traditional sense of course usually has performance
as a primary criterion.  For our purposes, it's near the bottom of
the list, even if we still feel some concern.

(Also, I think you might take a different approach if you did this
stuff test-driven instead of the traditional way (not sure if you've
caught the TDD bug yet...).  Python is *so* effective for this kind
of approach that it's hard to imagine being as productive with a
non-dynamic language.)


More information about the Python-list mailing list