[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2016-03-22 Thread Robert Siemer

Changes by Robert Siemer :


--
nosy: +siemer

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2015-05-16 Thread Nick Coghlan

Changes by Nick Coghlan :


--
versions: +Python 3.6 -Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2014-10-14 Thread Stefan Krah

Changes by Stefan Krah :


--
nosy:  -skrah

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2013-12-04 Thread Martin Panter

Changes by Martin Panter :


--
nosy: +vadmium

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2013-11-30 Thread Nick Coghlan

Changes by Nick Coghlan :


--
versions: +Python 3.5 -Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2013-08-16 Thread Lenard Lindstrom

Lenard Lindstrom added the comment:

A fourth way to add __getbuffer__ and __releasebuffer__ special methods to a 
Python class is through a new base class/mixin. The Py_buffer struct pointer 
passed to __getbuffer__ and __releasebuffer__ is wrapped with another special 
object type, which exposes the C struct fields as attributes. The base class is 
a direct subclass of object. Both the base and wrapper classes are implemented 
in an extension module. 

The use case is unit testing. A memoryview object may be adequate for simple 
C-contiguous arrays, but fails with F-contiguous or any non-contiguous array. 
It cannot export any arbitrary view, especially a deliberately invalid view, 
useful for testing error handlers.

My implementation is at https://bitbucket.org/llindstrom/newbuffer . It is used 
in Pygame 1.9.2 unit tests: https://bitbucket.org/pygame/pygame . The newbuffer 
module exports two classes, BufferMixin and Py_buffer. The BufferMixin class 
adds bf_getbuffer and bf_releasebuffer slot functions to base class PyObject, 
nothing more. The Py_buffer class is low level, exposing pointer fields as 
integer addresses. It is designed for use with ctypes and is modelled on 
ctypes.Structure.

Some limitations. In a class declaration, BufferMixin must be first in the 
inheritance list for the subclass to inherit the PEP 3118 interface. A buffer 
interface cannot be added to a builtin.

I suggest this is a practical alternative to the three previously proposed 
solutions to this issue. This option takes its precedence from the ctypes 
module, which adds dangerous memory level access to Python, but optionally. It 
does not require modification of the base code, only an addition to the 
standard library. Finally, this approach has been demonstrated in a real-world 
application.

--
nosy: +kermode
Added file: 
http://bugs.python.org/file31329/llindstrom-newbuffer-0dd8ba1c2c2c.tar.gz

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2013-06-15 Thread Jacob Holm

Changes by Jacob Holm :


--
nosy: +Jacob.Holm

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2012-07-07 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis :


--
nosy: +Arfrever

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2012-06-17 Thread Nick Coghlan

Nick Coghlan  added the comment:

I suggest a PEP for 3.4 as the best way forward for this.

--
versions: +Python 3.4 -Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2012-05-27 Thread Richard Oudkerk

Changes by Richard Oudkerk :


--
nosy: +sbt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2012-03-21 Thread Nick Coghlan

Nick Coghlan  added the comment:

The reason I don't particularly like the "delegation only" API is that the 
combination of the new memoryview implementation and bytes/mmap/etc to get a 
flat region of memory to play with means you could do some quite interesting 
things entirely at the Python level.

If you couldn't even use memoryview.cast() to change the shape of the exported 
memory, it makes the Python level API clearly inferior in power compared to 
what you can do in C.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2012-03-21 Thread Mark Dickinson

Changes by Mark Dickinson :


--
nosy: +mark.dickinson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2012-03-20 Thread Stefan Behnel

Stefan Behnel  added the comment:

Ok, just for the record: a single __buffer__() special method with 
delegation-only semantics would also work for Cython. Taking this path would 
provide a cleaner separation of the (then delegation-only) Python level 
protocol and the (all purpose) C level protocol. I think I'd prefer that.

I assume __buffer__() takes no arguments, right?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2012-03-20 Thread Alex Gaynor

Alex Gaynor  added the comment:

FWIW pypy has an __buffer__ method (used exclusively internally, AFAIK), which 
has semantics similar to your first proposal.

--
nosy: +alex

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2012-03-03 Thread Stefan Behnel

Stefan Behnel  added the comment:

FWIW, Cython lets user code implement the buffer interface for extension types 
using the special methods "__getbuffer__()" and "__releasebuffer__()", so 
providing the same methods (although with a different signature) also for 
normal Python types would IMHO fit nicely.

--
nosy: +scoder

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2012-03-01 Thread Eric Snow

Changes by Eric Snow :


--
nosy: +eric.snow

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2012-03-01 Thread Nick Coghlan

Nick Coghlan  added the comment:

To answer your other question, no, strview isn't related - that's strictly a 
PEP 3118 *consumer*, which is well supported from the Python side now that 
memoryview is fixed.

The trick will be to allow a Python implemented object to be a PEP 3118 
exporter *without* having to inherit from a C implemented type that does the 
slot mapping. Since PEP 3118 didn't describe a Python level API for the 
protocol, it may actually require a new PEP.

One example for what you could do with it: use the new memoryview.cast() to 
provide multidimensional views on an exporter that only supports 1D exports 
natively.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2012-03-01 Thread Nick Coghlan

Nick Coghlan  added the comment:

Consider a Python wrapper around a bytes object, or mmap or similar that
wants to pass PEP 3118 buffer requests through to the underlying object.
Currently, there's no way to write such a delegation - the delegating class
has to be written in C.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2012-03-01 Thread Stefan Krah

Stefan Krah  added the comment:

I'm trying to understand what you want to be able to write. Do you
perhaps have a short example? Also, to get the bigger picture: Is
this related to your strview proposal?

http://mail.python.org/pipermail/python-ideas/2011-December/012993.html

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2012-01-23 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2012-01-16 Thread Nick Coghlan

Nick Coghlan  added the comment:

Reviewing Stefan's work on #10181 suggests to me that option 3 is the only 
feasible approach.

(Allowing memoryview subclasses will permit types to pass their own state 
between __getbuffer__ and __releasebuffer__)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13797] Allow objects implemented in pure Python to export PEP 3118 buffers

2012-01-16 Thread Nick Coghlan

Changes by Nick Coghlan :


--
title: Add a Python level special method to retrieve a PEP 3118 object -> Allow 
objects implemented in pure Python to export PEP 3118 buffers

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com