Skip to main content

Linux AIO API wrapper

Project description

Linux AIO API wrapper

This is about in-kernel, file-descriptor-based asynchronous I/O. It has nothing to do with the asyncio standard module.

python 2 Notes

In python 2.7, a memoryview of a bytearray, despite being writable, is rejected by ctypes:

>>> from ctypes import c_char
>>> a = bytearray(b'foo')
>>> c_char.from_buffer(a)
c_char('f')
>>> b = memoryview(a)
>>> b.readonly
False
>>> c_char.from_buffer(b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: expected a writeable buffer object

This means that it is not possible to only read or write a few bytes at the beginning of a large buffer without having to copy memory.

The same code works fine with python 3.x .

This is considered a python 2.7 ctypes or memoryview bug, and not a python-libaio bug.

Also, memoryview refuses to use an mmap object:

>>> import mmap
>>> a = mmap.mmap(-1, 16*1024)
>>> b = memoryview(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot make memory view because object does not have the buffer interface
>>>

…but ctypes is happy with it:

>>> import ctypes
>>> c = (ctypes.c_char * len(a)).from_buffer(a)
>>>

…and memoryview accepts being constructed over ctype objects:

>>> d = memoryview(c)
>>>

…and it really works !

>>> a[0]
'\x00'
>>> c[0]
'\x00'
>>> d[0]
'\x00'
>>> d[0] = '\x01'
>>> c[0]
'\x01'
>>> a[0]
'\x01'
>>> a[0] = '\x02'
>>> c[0]
'\x02'
>>> d[0]
'\x02'

This is considered a python 2.7 memoryview or mmap bug.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libaio-0.5.tar.gz (9.7 kB view details)

Uploaded Source

File details

Details for the file libaio-0.5.tar.gz.

File metadata

  • Download URL: libaio-0.5.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for libaio-0.5.tar.gz
Algorithm Hash digest
SHA256 7002b99aa4e27297bc1775eea1bf5dd78ee90c38557dee7cbad9224971555613
MD5 221e2c99b21656c7729ba8c4ecfbc596
BLAKE2b-256 419331f56257a602544028e8223a129f297b5781472a72020e9243a36b0570f3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page