I think you can use python itself for "pre-processing". Here is an
(shortened) example from PyPy RPython paper:
# operators: the docstrings contain the
# symbol associated with each operator
class Op_Add(BinaryExpr):
’+’
class Op_Sub(BinaryExpr):
’-’
# INIT-TIME only: build the table of
#
Santiago Romero wrote:
Can the above be easily done with another already-existing
application? (example: can m4 do this job)?
The problem you're going to have with something like
m4 is indentation. When you inline a function call,
somehow the inserted code has to be shifted to the
same indent
Try creation an extension module with ShedSkin.
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
En Thu, 12 Nov 2009 23:29:03 -0300, greg
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 dic
I'm going to quote all the answers in a single post, if you all don't
mind:
> [greg]
> 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 nu
> How about
> page, index = divmod(address, 16384)
Surely, much better and faster :-)
Thanks a lot.
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 12, 6:29 pm, greg wrote:
> I would be taking a different approach -- develop a prototype
> in Python, concentrating on clarity rather than speed, and
> later reimplement the core of the emulator as an extension
> module, using Pyrex or Cython or otherwise.
But keep in mind he said he was d
On Nov 12, 6:37 am, Santiago Romero wrote:
> > > I'm trying to port (just for fun), my old Sinclair Spectrum emulator,
> > > ASpectrum, from C to Python + pygame.
>
> > The answer to your question is, "Use numpy". More details below.
>
> Let's see :-)
>
> > > How can I implement this in Python
On Fri, 13 Nov 2009 15:33:53 +1300, greg wrote:
> Santiago Romero wrote:
>>>How about
>>>page, index = divmod(address, 16384)
>>
>> Surely, much better and faster :-)
>
> Not necessarily, because it involves a function call, and constructing
> and deconstructing a result tuple. If you time t
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 n
Santiago Romero wrote:
How about
page, index = divmod(address, 16384)
Surely, much better and faster :-)
Not necessarily, because it involves a function call,
and constructing and deconstructing a result tuple.
If you time them, you may well find that the explicit
shift and mask operation
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 s
Oops, numpy arrays start with index=0 :-)
--
http://mail.python.org/mailman/listinfo/python-list
> 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 d
Santiago Romero wrote:
I'm trying to port (just for fun), my old Sinclair Spectrum emulator,
A
Do you mean:
page =ddress / 16384
index =ddress MOD 16384
?
Or, better, with:
page =ddress >> 14
index =ddress & 16383
?
How about
page, index = divmod(address, 16384)
> > I'm trying to port (just for fun), my old Sinclair Spectrum emulator,
> > ASpectrum, from C to Python + pygame.
>
> The answer to your question is, "Use numpy". More details below.
Let's see :-)
> > How can I implement this in Python, I mean, define a 16 byte variable
> > so that high and
On Nov 12, 4:35 am, Santiago Romero wrote:
> Hi.
>
> I'm trying to port (just for fun), my old Sinclair Spectrum emulator,
> ASpectrum, from C to Python + pygame.
The answer to your question is, "Use numpy". More details below.
[snip]
> Should I start writing all the code with a Z80CPU obj
Hi.
I'm trying to port (just for fun), my old Sinclair Spectrum emulator,
ASpectrum, from C to Python + pygame.
Although the Sinclair Spectrum has a simple Z80 8 bit 3.5Mhz
microprocessor, and no aditional hardware (excluding the +2/+3 model's
AYsound chip), I'm not sure if my loved scripted
18 matches
Mail list logo