Nick Coghlan <ncoghlan@gmail.com> wrote:
I took Jeff's question as being slightly different and applying in the following situations:
I think I attempted to answer the same thing. :)
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?
No, this is definitely disallowed by the PEP (PyBUF_FORMAT): "If format is not explicitly requested then the format must be returned as NULL (which means "B", or unsigned bytes)."
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?
Also explicitly disallowed (PyBUF_ND): "If this is not given then shape will be NULL."
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?
This is not explicitly disallowed, but IMO the intent is that strides should also be NULL in that case. For example, strides==NULL might be used for a quick C-contiguity test. Stefan Krah