Concerns about performance w/Python, Pysco on Pentiums

Andrew Bennetts andrew-pythonlist at puzzling.org
Fri Mar 7 06:05:26 EST 2003


On Fri, Mar 07, 2003 at 11:26:38AM +0100, CezaryB wrote:
> On 3/6/03 8:35 PM, Peter Hansen wrote:
> 
> >    def step(self):
> 
> >        opcodeByte = self.readByte(self.PC)
> >        try:
> >            opcode = self.opcodes[opcodeByte]
> >        except KeyError:
> >            raise UnimplementedOpcode('$%02X %s' % (opcodeByte,
> >self.readMemory(self.PC + 1, 5)))
> >        else:
> >            deltaPC, self.effectiveAddress = 
> >            self.resolveAddress(opcode.mode)
> >            newPC = opcode.execute(self)
> >
> >            if newPC is not None:
> >                self.PC = newPC
> >            else:
> >                self.PC += deltaPC + opcode.length
> >
> >            self.cycles += opcode.cycles
> >   ...
> Inline "step" in your main loop, use local variables instead od self.PC, 
> self.opcodes self.resolveAddress. It should help Psyco.

Regarding inlining, I thought psyco would do it automatically?

Hmm, another thought... does this code use __slots__?  Do they make any
measureable difference to performance?  (I'm wondering if they improve
locality and memory footprint enough to have noticeable cache benefits)

-Andrew.






More information about the Python-list mailing list