[Python-Dev] Understanding the buffer API

Nick Coghlan ncoghlan at gmail.com
Sat Aug 4 17:35:00 CEST 2012


On Sun, Aug 5, 2012 at 1:25 AM, Stefan Krah <stefan at bytereef.org> wrote:
> In most cases it won't matter. However, a consumer is entitled to rely
> on shape==NULL in response to a PyBUF_SIMPLE request. Perhaps there
> is code that tests for shape==NULL to determine C-contiguity.
>
> This is an example that might occur in C. You hinted at the fact that not
> all of this may be relevant for Java, but on that I can't comment.

Think about trying to specify the buffer protocol using only C++
references rather than pointers. In Java, it's a lot easier to say
"this value must be a reference to 'B'" than it is to say "this value
must be NULL". (My Java is a little rusty, but I'm still pretty sure
you can only get NullPointerException by messing about with the JNI).

I think it's worth defining an "OR" clause for each of the current "X
must be NULL" cases, where it is legal for the provider to emit an
appropriate non-NULL value that would be consistent with the consumer
assuming that the returned value is consistent with what they
requested.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list