Automatic Generation of Python Class Files

Chris Mellon arkanes at
Tue Oct 30 13:01:58 CET 2007

On Oct 30, 2007 5:52 AM, Fuzzyman <fuzzyman at> wrote:
> On Oct 29, 11:35 pm, Steven Bethard <steven.beth... at> wrote:
> > Fuzzyman wrote:
> > > On Oct 22, 6:43 pm, Steven Bethard <steven.beth... at> wrote:
> > >> # Inherit from object. There's no reason to create old-style classes.
> >
> > > We recently had to change an object pipeline from new style classes to
> > > old style. A lot of these objects were being created and the *extra
> > > overhead* of new style classes was killing us. :-)
> >
> > I'm curious.  Was it memory or speed overhead that was the problem?
> It was speed overhead - I have to add a disclaimer that this is
> IronPython, but my understanding is that the situation is similar with
> CPython. Creating new style class instances is slower than for old
> style classes.

The obvious timeit test shows new-style classes being created in half
the time of old style ones. I certainly would not generalize to
CPython from IronPythons performance characteristics, especially with
something that's so dependent on both the .NET runtime and on the
details of IronPython integration as object creation.

C:\>python -m timeit -s "class C: pass" "c = C()"
1000000 loops, best of 3: 0.315 usec per loop

C:\>python -m timeit -s "class C(object): pass" "c = C()"
10000000 loops, best of 3: 0.175 usec per loop

More information about the Python-list mailing list