Dag Sverre Seljebotn wrote: > To be even more specific: Slices. arr[1:4] should return a Python > object, arr[1] should return a single item of native type. Both calling > methods uses __getitem__ in Python.
That's something of a problem, but I don't see how trying to sort it out based on what's being done with the return value will work in general. What happens if the return value is being passed to another function as a parameter of type 'generic'? However, this may not be as much of a problem as it looks. When the slice indices are written directly in the indexing expression like that, you know that the argument to __getitem__ isn't just any kind of object, it's an object of type 'slice'. So you have at least three possible signatures for __getitem__: __getitem__(int) -> element type of array # optimised __getitem__(slice) -> python object # optimised __getitem__(object) -> python object # unoptimised You could go further and have finer specialisations of type 'slice' according to the number of indices, etc., allowing different code to be generated for each case. -- Greg _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
