2012/9/20 David Beazley <d...@dabeaz.com>:
> I have recently been experimenting with the memoryview() built-in and have 
> come to believe that it really needs to expose the 'buf' attribute of the 
> underlying Py_buffer structure as an integer (see PEP 3118).  Let me explain.
>
> The whole point of PEP 3118 (as I understand it) is to provide a means for 
> exchanging or sharing array data across different libraries such as numpy, 
> PIL, ctypes, Cython, etc.   If you're working with Py_buffer objects at the C 
> level, this works fine.  However, if you're working purely in Python, you're 
> only able to get partial information about memory views such as the shape and 
> size.   You can't get the actual pointer to the underlying memory (unless 
> I've missed something obvious).
>
> This is unfortunate because it means that you can't  write Python code to 
> link memoryviews to other kinds of compiled code that might want to operate 
> on array-oriented data.  For example, you can't pass the raw pointer into a 
> function that you've exposed via ctypes.  Similarly, you can't pass the 
> pointer into functions you've dynamically compiled using libraries such as 
> LLVM-py.     There might be other kinds of applications, but just having that 
> one bit of extra information available would be useful for various advanced 
> programming techniques involving extensions and memory buffers.

Presumably ctypes should be able to do this conversion for you.



-- 
Regards,
Benjamin
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to