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

Re: [pygame] 2D vector class



On 8/15/06, Marius Gedminas <mgedmin@xxxxxxxx> wrote:
> [slots for performance]

__slots__ is for optimizing memory usage, not speed.

optimizing memory usage is not mutually exclusive to optimizing speed

One thing that It took me a long time to fully realize (years really)
as a c++ programmer, is the incredibly large impact of memory
allocations on performance - I mean like 3x or 4x times difference
kind of performance.

From what I read about slots, it seemed like they could make it
possible for python to do much fewer allocations for an object in that
it wouldn't have to allocate properties dynamically, cause when the
object was allocated, it could allocate space for the properties at
the same time.