Re: Jython buffer protocol

"Stefan Richthofer" <[email protected]>
Newsgroups gmane.comp.lang.jython.devel
Message-ID <trinity-2765c879-b78d-45d3-b252-c419dd6bda9d-1407513686980@3capp-gmx-bs47>
> I was rather asking whether the use case 
> was served adequately by the addition of PyBUF.AS_ARRAY, hasArray() and 
> getNIOByteBuffer(), since you obviously have a clear idea of it.
Yes, it is served (at least use case of exposing Buffer Protocol of C-PyObjects in Java)

I read the change set again, but found nothing problematic. Just two doc-remarks:

In the doc of hasArray():

line 276
the sentence seems to be malformed, I think there is a "to" missing.
"Determine whether the exporter is able to offer direct access >>to<< the exported storage as a Java byte array"

line 280
"@return true if array access is not allowed, false if it is."
It should be the other way round, shouldn't it?
return true if array access is allowed, false if it is not.
Additionally I would suggest to replace "allowed" by "supported and allowed" since array
access might be technically unavailable rather than not granted because of rights.


> I took a second/third look but didn't find anything to change in 
> BaseBytes and PyByteArray: when arguments objects have the Buffer API 
> they are accessed through the abstract API (not as byte[]). PyByteArray 
> obviously can support AS_ARRAY, and that seems to be covered in 
> SimpleBuffer.
I also took a second look and agree there is nothing to change for now; sorry for the wrong alert!.
(Still curious to get direct ByteBuffer backend support there one day).


> I think it would make sense to have a layer below BaseBytes that 
> contained all those mechanisms that work without assuming a byte[] 
> storage. This would help you implement PyBuffer in an object unable to 
> export a byte[]. That wouldn't change the API and is likely harmless to 
> efficiency. But more radical ideas, I agree, need more careful thought. 
> (The present design has had a lot of thought.)
Alright. I think it would be best to resume the discussion about this, when
I actually start to work on Buffer Protocol support in JyNI.

Thanks for this work!

Stefan

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.