On May 11, 2008, at 2:50 AM, Greg Ewing wrote:
> Another thing to consider is how this would
> interact with subclassing. Will it be legal
> to do something like
>
> cdef class B(A(len=10)):
> ...
>
> and if so, how does the initialisation of B
> ensure that the length constraint is satisfied?
No, I don't think the above would be allowed. One would do
cdef class B(A):
...
cdef B(len=1) b
It should also be noted that some of the stuff being discussed here
circumvents subclassing--the prototypical example is if x is a NumPy
array with float entries then
x[i]
can be accessed directly via internal knowledge of the internal
layout of the type of x. If x is an instance of a subclass that
overrides __getitem__ to do something different this will break. This
is bad, but so is manually hard-coding against the internal structure
of x, and accessing arrays via __getitem__ is just way to slow for
serious numerical algorithms. (Yes, you could say "just use a
float*", but NumPy provides a lot of niceites, among them interfacing
well with pure Python code and memory management).
- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev