class C: vs class C(object):

sjdevnull at yahoo.com sjdevnull at yahoo.com
Fri Jul 20 05:18:47 EDT 2007


Aahz wrote:
> In article <f7oplv$fn9$1 at zinnia.noc.ucla.edu>,
> James Stroud  <jstroud at mbi.ucla.edu> wrote:
> >Aahz wrote:
> >> In article <pan.2007.07.19.08.09.59.261957 at REMOVE.THIS.cybersource.com.au>,
> >> Steven D'Aprano  <steve at REMOVE.THIS.cybersource.com.au> wrote:
> >>>
> >>>It isn't wrong to use the old style, but it is deprecated, [...]
> >>
> >>
> >> Really?  Can you point to some official documentation for this?  AFAIK,
> >> new-style classes still have not been integrated into the standard
> >> documentation.  Maybe I missed something, though.
> >>
> >> Note very carefully that "going away eventually" is *not* the same as
> >> deprecation.
> >
> >How about "broke" instead of "deprecated":
> >
> >
> > >>> class Old:
> >...   def __init__(self):
> >...     self._value = 'broke'
> >...   value = property(lambda self: self._value)
> >...
>
> How is this broken?  Properties are not supported for old-style classes.
> They may not support features introduced in new-style classes, but that's
> hardly the same as "broken".

In particular, old-style classes are noticeably faster than new-style
classes for some things (I think it was attribute lookup that
surprised me recently, possibly related to the property stuff...)




More information about the Python-list mailing list