[New-bugs-announce] [issue2655] Create ctypes instances from buffer interface

Thomas Heller report at bugs.python.org
Fri Apr 18 20:31:04 CEST 2008

New submission from Thomas Heller <theller at ctypes.org>:

This patch implements a .from_buffer(source, offset=0) class method from
ctypes types.  'source' must expose a writeable buffer interface; the
created ctypes instance will share the internal buffer of the source
object; also it holds a reference to the source object to keep it alive.

The usual problems with the buffer interface are not hidden.

Open question:
Should there be an additional 'copy_from_buffer' class method that
accepts read-only buffer interface (as an alternative, an optional
'copy=False' parameter could be introduced)?

assignee: theller
components: ctypes
files: from_buffer.patch
keywords: patch, patch
messages: 65620
nosy: theller
severity: normal
status: open
title: Create ctypes instances from buffer interface
versions: Python 2.6
Added file: http://bugs.python.org/file10057/from_buffer.patch

Tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list