[Cython] Surprising behaviour wrt. generated tp_clear and tp_dealloc functions

Stefan Behnel stefan_ml at behnel.de
Tue Apr 23 10:09:12 CEST 2013


Torsten Landschoff, 23.04.2013 10:06:
> On 04/23/2013 08:01 AM, Stefan Behnel wrote:
>> Greg Ewing, 23.04.2013 01:16:
>>> Only if subclassing of Slot and Context are forbidden.
>> Right. Subtypes of a non-GC type can happily add attributes and start
>> supporting cyclic garbage collection, including Python subclasses. So this
>> only applies to "final" types and builtins. Not entirely uncommon,
>> especially in the "keep this private thing alive until all referrers have
>> died" use case, but I's say this restriction drops the priority a bit.
>>
> Does Cython have an equivalent of the "final class DoNoExtend { ... }"
> of the Java world?

  @cython.final
  cdef class ExtType:
      ...

You can also declare a class @cython.internal to prevent it from showing up
in the module dict.

Stefan



More information about the cython-devel mailing list