[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Python and Speed



René Dudfield wrote:

2. - asm optimizations.  There seems to be
almost no asm optimizations in CPython.

That's a deliberate policy. One of the goals of CPython
is to be very portable and written in a very straightforward
way. Including special pieces of asm for particular
architectures isn't usually considered worth the
maintenance effort required.

CPython could use faster threading
primitives, and more selective releasing of the GIL.

Everyone would love to get rid of the GIL as well, but
that's another Very Hard Problem about which there has
been much discussion, but little in the way of workable
ideas.

A way to know how much memory is being used.
Memory profiling is the most important way to optimize since memory
is quite slow compared to the speed of the cpu.

Yes, but amount of memory used doesn't necessarily
have anything to do with rate of memory accesses.
Locality of reference, so that things stay in the
cache, is more important.

perhaps releasing
a patch with a few selected asm optimizations might let the python
developers realise how much faster python could be...

Have you actually tried any of this? Measurement
would be needed to tell whether these things address
any of the actual bottlenecks in CPython.

> a slot int attribute takes up 4-8 bytes, whereas a python int
attribute takes up (guessing) 200 bytes.

Keep in mind that the slot only holds a reference --
the actual int object still takes up memory elsewhere.
Slots do reduce memory use somewhat, but I wouldn't
expect that big a ratio.

--
Greg