[Cython] class optimisations (Re: [cython-users] How to pass Cython flags from Distutils?)

Stefan Behnel stefan_ml at behnel.de
Tue Apr 3 13:59:56 CEST 2012

[moving this discussion from cython-users to cython-devel]

Robert Bradshaw, 03.04.2012 09:43:
> On Mon, Apr 2, 2012 at 11:01 PM, Stefan Behnel wrote:
>> Robert Bradshaw, 03.04.2012 07:51:
>>> auto_cpdef is expiremental
>> Is that another word for "deprecated"?
> No, it's another word for "incomplete."

Ah, just a typo then.

> Can something be deprecated if
> it was never even finished? It's probably something we should
> eventually do by default as an optimization, at least for methods, as
> well as letting compiled classes become cdef classes (minus the
> semantic idiosyncrasies) whenever possible (can we always detect this?

We can at least start with the "obviously safe" cases, assuming we find
any. A "__slots__" field would be a good indicator, for example. And when
we get extension types to have a __dict__, that should fix a lot of the
differences already.

> What about subclasses that want to multiply-inherit?

You can inherit from multiple extension types in a Python type, and classes
with more than one parent aren't candidates anyway. So this doesn't
restrict us.

> It may still be
> an option worth finishing up, making it easy to automatically take a
> (slightly-incompatible) step towards static binding.

Yes, the option could be extended to include classes at some point, before
we go for more automatic default optimisations. That would keep the changes
explicit at the beginning.


More information about the cython-devel mailing list