Writing an emulator in python - implementation questions (for performance)
Santiago Romero
sromero at gmail.com
Thu Nov 12 12:41:47 EST 2009
> You can do clever memory slicing like this with numpy. For instance:
>
> breg = numpy.zeros((16,),numpy.uint8)
> wreg = numpy.ndarray((8,),numpy.uint16,breg)
>
> This causes breg and wreg to share the same 16 bytes of memory. You
> can define constants to access specific registers:
What I'm doing wrong?
[sromero at compiler:~]$ cat test.py
#!/usr/bin/python
import numpy
# Register array
breg = numpy.zeros((16,),numpy.uint8)
wreg = numpy.ndarray((8,), numpy.uint16, breg )
reg_A = 1
reg_F = 2
reg_AF = 1
reg_B = 3
reg_C = 4
reg_BC = 3
breg[reg_B] = 5
breg[reg_C] = 10
print breg[reg_B]
print breg[reg_C]
print wreg[reg_BC]
[sromero at compiler:~]$ python test.py
5
10
0
?
More information about the Python-list
mailing list