On Sun, Oct 31, 2010 at 6:56 AM, Stefan Behnel <[email protected]> wrote:
> Lisandro Dalcin, 31.10.2010 08:22:
>> On 31 October 2010 10:09, Robert Bradshaw wrote:
>>> What about using the
>>>
>>> [cdef] class A:
>>>     ...
>>>
>>> del A
>>>
>>> idiom that people use for pure Python?
>>
>> I have to admit that this looks even simpler.
>
> Emphasis on "looks". I can see this easily working for Python classes, but
> what would be the semantics for cdef classes? Would it have any impact on
> their accessibility from Cython, and more specifically, from inside of the
> module that defines the type? What if a user externally overrides a Python
> class as cdef class in pure mode? And would it (or should it ever) be
> possible to redefine the type after deleting it? Should Cython prevent this
> for public/api classes, or would you just get the ImportError at runtime
> when it tries to read the type from the module dict?

Personally, I would not be opposed to putting everything into the
__pyx_api object rather than loading anything from the module dict.
That would be safer for one thing.

> Or would you just say "well, it's not really 'del' what's happening here,
> it's something that looks like Python, doesn't have an immediate impact,
> but removes the name from something that you can't see in your code"?
>
> The advantage of a decorator is that it's easy to get right, to read and
> comprehend. I'm not really opposed to using "del" here, but I'm not sure I
> can oversee all the implications of allowing it on cdef types.

I would say that "del" simply removes things from the Python
namespace. The c namespace is fixed at compile time, and would remain
so. This is essentially the case already, though perhaps we disallow
del for cdef classes as they live in both namespaces (don't know).

My main objection is that this decorator is yet another thing that
doesn't, and cannot, have an exact Python equivalent, and there's a
reasonable and widespread Python idiom to use in this case. We'd
probably want to support del on cdef classes for pure Python mode
anyways.

- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to