Optimizing Object Instantiation (was Re: How Fast Does Python Run?)

Sam Penrose see at message.body
Sun Jun 18 18:58:24 EDT 2000


In article <E0Y25.1541$qz4.13200 at news-server.bigpond.net.au>, "Mark 
Hammond" <mhammond at skippinet.com.au> wrote:

> "Sam Penrose" <see at message.body> wrote in message
> news:see-0F7889.18054217062000 at news.dnai.com...
> 
> > 1) Does informed opinion agree that object instantiation is
> > noticeably performance-expensive in CPython? (Unfortunately,
> > I can't seem to find the article in question.)
> 
> Sorry - no informed opinions here :-)
> 
> But I would guess that "type" creation (ie, creation of objects
> implemented in extension modules) would be quite fast, and mainly
> dependent on the native malloc() speed.
> 
> I could well believe that "instance" creation (ie, creation of user
> defined class instances) would be quite slow, especially if the object in
> question has an __init__ function!
> 
> Mark.

The code in question is based around nested __init__ calls:
a main working class which is based on an abstract class
(2 __inits__) and which calls a wrapper class (3) around the
MySQLdb module (4).

I'm starting to think for other reasons that I've been
overcoding, but it would be nice to know whether the
performance issue has any prospects of being addressed.

OTOH, it's amazing how much faster $2,500 worth of current
hardware is than the system we spent $2,500 on two years ago;
perhaps the point will prove moot.



More information about the Python-list mailing list