Writing an emulator in python - implementation questions (for performance)
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Fri Nov 13 07:53:02 EST 2009
En Thu, 12 Nov 2009 23:29:03 -0300, greg <greg at cosc.canterbury.ac.nz>
escribió:
> Carl Banks wrote:
>> You
>> can define constants to access specific registers:
>> R1L = 1
>> R1H = 2
>> R1 = 1
>> breg[R1H] = 2
>> print wreg[R1]
>
> But keep in mind that named "constants" at the module level
> are really global variables, and therefore incur a dictionary
> lookup every time they're used.
>
> For maximum speed, nothing beats writing the numeric literals
> directly into the code, unfortunately.
This recipe may improve speed dramatically in those cases:
http://code.activestate.com/recipes/277940/
--
Gabriel Genellina
More information about the Python-list
mailing list