ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> pygame-users
pygame-users
Re: [pygame] 2D vector class
by Lenard Lindstrom other posts by this author
Aug 22 2006 9:58AM messages near this date
Re: [pygame] 2D vector class | Re: [pygame] 2D vector class
On 21 Aug 2006 at 23:48, Brian Fisher wrote:

>  On 8/15/06, Marius Gedminas <mgedmin@[...].lt> 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.
>  
Slots replace memory allocated in a dictionary. But if any attribute 
goes into an instance dict then the benefit is probably lost. More 
important, slots simplify the attribute lookup process. Slots use 
automatically generated descriptors, one for each slot. Descriptors 
override normal attributes. Every attribute lookup starts with a 
descriptor search. The instance dict is searched only if one is not 
found. So having a descriptor reduces the search time. And a slot 
descriptor does not do a dict lookup. So slots should be faster, 
though I have not confirmed it.

Lenard Lindstrom
<len-l@[...].net> 
Thread:
Scott Nelson
Marius Gedminas
Brian Fisher
Scott Nelson
Brian Fisher
Alex Holkner
Brian Fisher
Brian Fisher
Ethan Glasser-Camp
Matthias Baas
Alex Holkner
Brian Fisher
Marius Gedminas
Brian Fisher
Lenard Lindstrom
Richard Jones
Richard Jones
Matthias Baas
Greg Ewing
Richard Jones
Greg Ewing
Ethan Glasser-Camp

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved