Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Getting a locked buffer from objects (PEP 3118)

Reply
Thread Tools

Getting a locked buffer from objects (PEP 3118)

 
 
KKH
Guest
Posts: n/a
 
      12-25-2008
Hi,

it seems the whole locking-theme has gone from PEP 3118 (PyBUF_LOCK is gone). Yet the string and byte objects seem to provide locked buffers through PyArg_Parse arguments s*, y* and z* (documentation says so).

Could someone please clarify the situation for me: Is it save to release the GIL after getting a reference to a buffer-object by the arguments above and only talking to this buffer while the GIL is gone?

And while we are at it Is "PyArg_Parse('[syz]*'..." the only way to get a locked buffer-view from string/byte objects?

Regards
ebfe



 
Reply With Quote
 
 
 
 
Stefan Behnel
Guest
Posts: n/a
 
      12-27-2008
KKH wrote:
> it seems the whole locking-theme has gone from PEP 3118 (PyBUF_LOCK is
> gone). Yet the string and byte objects seem to provide locked buffers
> through PyArg_Parse arguments s*, y* and z* (documentation says so).


Might be a left-over. All locking the buffer interface itself provides is
the guarantee that the buffer will not move between getting and releasing a
buffer. Everything else must be handled at the application level.


> Could someone please clarify the situation for me: Is it save to release
> the GIL after getting a reference to a buffer-object by the arguments
> above and only talking to this buffer while the GIL is gone?


The buffer interface is a pure C level interface. All you get is a pointer
to a memory buffer plus some meta data. No Python references are involved
from that point on. So it only depends on your own code if it's safe to
free the GIL or not.


> And while we are at it Is "PyArg_Parse('[syz]*'..." the only way to
> get a locked buffer-view from string/byte objects?


What kind of locking do you need?

Stefan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
buffer creates only read-only buffer? Neal Becker Python 0 01-08-2009 01:58 AM
When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer? DR ASP .Net 2 07-29-2008 09:50 AM
When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer? DR ASP .Net Building Controls 0 07-29-2008 01:37 AM
convert M bit buffer to N bit buffer runcyclexcski@yahoo.com C++ 2 03-26-2007 09:43 AM
How to know the buffer size and increase buffer size in c++ Raja C++ 12 06-21-2004 06:21 PM



Advertisments