[Python-Dev] Understanding the buffer API

Nick Coghlan ncoghlan at gmail.com
Sat Aug 4 16:51:06 CEST 2012


On Sat, Aug 4, 2012 at 7:11 PM, Stefan Krah <stefan at bytereef.org> wrote:
> You are right that the PEP does not explicitly state that rule for
> strides. However, NULL always has an implied meaning:
>
>   format=NULL  ->  treat the buffer as unsigned bytes.
>
>   shape=NULL   ->  one-dimensional AND treat the buffer as unsigned bytes.
>
>   strides=NULL ->  C-contiguous
>
>
> I think relaxing the NULL rule for strides would complicate things,
> since it would introduce yet another special case.

I took Jeff's question as being slightly different and applying in the
following situations:

1. If the consumer has NOT requested format data, can the provider
return accurate format data anyway, if that's easier than returning
NULL but is consistent with doing so?

2. The consumer has NOT requested shape data, can shape data be
provided anyway, if that's easier than returning NULL but is
consistent with doing so?

3. The consumer has NOT requested strides data, can strides data be
provided anyway, if that's easier than returning NULL but is
consistent with doing so?

That's what I believe is Jeff's main question: is a provider that
always publishes complete information, even if the consumer doesn't
ask for it, in compliance with the API, so long as any cases where the
consumer's stated assumption (as indicated by the request flags) would
be violated are handled as errors instead of successfully populating
the buffer?

Cheers,
Nick.

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


More information about the Python-Dev mailing list