Robert Bradshaw wrote:
> On Aug 4, 2008, at 7:37 AM, Dag Sverre Seljebotn wrote:
>> (While on namespace issues, the Tao says "flat is better than nested"
>> which is in favor of cython.shape rather than cython.buffer.shape?)
>
> Because "shape" is generic enough could very well have other meanings
> that are completely unrelated to buffers, and I'd rather have
> cython.buffer.shape than cython.buffer_shape.

(I hit the result_code wall with these functions, so this discussion lost
its importance for some days at least. But for the record:)

Python doesn't have "list_len", "tuple_len" etc. Even if shape should get
more meanings (which I doubt), cython.shape is likely to mean "get the
shape of my argument", so you differ the meanings by the type (just like
"len" does). We can't add slots, but instead we have compile-time
information.

The point is getting a natural pattern people can use for looping and
which they don't have to think too much about -- I'd like to "hide"
buffers from the average NumPy user. Currently there's nothing requiring a
NumPy user to know about the buffer PEP (it "just works"), this import
would be the only place the word "buffer" shows up and it kind of makes it
"less integrated" and less Pythonic (kind of like requiring you to call
list_len).

(Thought experiment: In line with this, one could have shape try to return
the right thing for regularily-sized nested Python lists as well. Not that
it is worth doing, but if one wanted to, it would be natural to have that
functionality below the same shape name in the namespace.)

- In the case of buffer_pointer, it would be confusing to have just
"pointer" anyway, so you would need cython.buffer.buffer_pointer.

- ndim seems to be like shape.

- strides and suboffsets are quite buffer-specific though.

I'm still for "flat better than nested", but failing that, I'd propose
that everything is in cython.buffer but shape is also in cython.

Dag Sverre

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

Reply via email to