Skip to main content

High-performance async file I/O for Python (C++23 backend)

Project description

aiofiles-x
High-Performance Async File I/O for Python
Homepage Documentation News

aiofiles-x

Python 3.10+ C++23 License: AGPL v3

Elegant, modern and high-performance async file I/O library for Python

import asyncio
import aiofiles

async def main():
    async with aiofiles.open('file.txt', 'w') as f:
        await f.write('Hello from aiofiles-x!')

    async with aiofiles.open('file.txt', 'r') as f:
        content = await f.read()
        print(content)

asyncio.run(main())

aiofiles-x is a modern, elegant and high-performance async file I/O library for Python. It is a C++23 reimplementation of aiofiles with 100% API compatibility, providing up to 3.79× faster small file reads, 3.41× faster concurrent operations, and 2.08× faster medium file operations (100KB) while maintaining the same simple and intuitive interface.

⚠️ Note: Performance results may vary depending on hardware specifications, operating system, and workload patterns.

Key Features

  • Ready: Install aiofiles-x with pip and start building your applications right away.
  • Easy: Simple and intuitive API that's fully compatible with the original aiofiles.
  • Elegant: Clean async/await syntax that integrates seamlessly with asyncio.
  • Fast: Powered by C++23 backend for maximum performance and efficiency.
  • Type-hinted: Fully type-annotated for excellent editor support and type checking.
  • Async: Fully asynchronous file operations without blocking the event loop.
  • Compatible: 100% API compatible with aiofiles - drop-in replacement ready.

Installing

Stable version

pip install aiofiles-x

From GitHub release

pip install https://github.com/ohmyarthur/aiofiles-x/releases/download/v1.0.2/aiofiles_x-1.0.2.tar.gz

API Reference

Core Operations

import aiofiles

# File operations
async with aiofiles.open('file.txt', 'r') as f:
    data = await f.read()
    await f.write(data)
    await f.seek(0)
    line = await f.readline()
    async for line in f:
        process(line)

# Temp files
async with aiofiles.tempfile.NamedTemporaryFile('w+') as tmp:
    await tmp.write('temp data')

# OS operations
await aiofiles.os.remove('file.txt')
await aiofiles.os.mkdir('directory')
files = await aiofiles.os.listdir('.')

Supported Methods

  • read(), write(), readline(), readlines(), writelines()
  • seek(), tell(), truncate(), flush()
  • close(), isatty(), seekable(), writable()
  • All aiofiles.os and aiofiles.tempfile operations

Build from Source

git clone https://github.com/ohmyarthur/aiofiles-x.git
cd aiofiles-x
pip install .

Requirements: Python 3.10+, C++23 compiler (GCC 12+, Clang 15+), CMake 3.20+

Manual Development

# Install dev dependencies
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

# Run tests
pytest tests/unit -v

# Run benchmarks
pytest tests/benchmarks/benchmark_performance.py --benchmark-only

# Code quality checks
make lint          # Check code style
make format        # Auto-format code
make pre-commit-run  # Run all checks

Pre-commit Hooks

This project uses pre-commit for code quality:

  • Python: black, ruff, mypy
  • C++: clang-format
  • Security: bandit, detect-secrets
  • Commits: Conventional commit format
  • Docs: markdownlint
# Install hooks
pre-commit install

# Run manually
pre-commit run --all-files

Resources

  • Check out the documentation to learn more about aiofiles-x, get started right away and discover more in-depth material for building your applications.
  • Visit the changelog and stay tuned for news, updates and announcements.

License

License

aiofiles-x is licensed under GNU Affero General Public License v3 or later.

Inspired by: aiofiles (Apache 2.0)

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

aiofiles_x-1.0.2.tar.gz (40.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

aiofiles_x-1.0.2-cp312-cp312-win_amd64.whl (99.6 kB view details)

Uploaded CPython 3.12Windows x86-64

aiofiles_x-1.0.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (165.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

aiofiles_x-1.0.2-cp312-cp312-macosx_11_0_arm64.whl (146.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

aiofiles_x-1.0.2-cp312-cp312-macosx_10_13_x86_64.whl (143.5 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

aiofiles_x-1.0.2-cp311-cp311-win_amd64.whl (100.6 kB view details)

Uploaded CPython 3.11Windows x86-64

aiofiles_x-1.0.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (166.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

aiofiles_x-1.0.2-cp311-cp311-macosx_11_0_arm64.whl (147.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

aiofiles_x-1.0.2-cp311-cp311-macosx_10_13_x86_64.whl (144.5 kB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

aiofiles_x-1.0.2-cp310-cp310-win_amd64.whl (99.2 kB view details)

Uploaded CPython 3.10Windows x86-64

aiofiles_x-1.0.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (165.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

aiofiles_x-1.0.2-cp310-cp310-macosx_11_0_arm64.whl (146.8 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

aiofiles_x-1.0.2-cp310-cp310-macosx_10_13_x86_64.whl (143.6 kB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

Details for the file aiofiles_x-1.0.2.tar.gz.

File metadata

  • Download URL: aiofiles_x-1.0.2.tar.gz
  • Upload date:
  • Size: 40.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiofiles_x-1.0.2.tar.gz
Algorithm Hash digest
SHA256 54f11bdf0e4f0d9404e7bd172bd95cfbf8bf467125770e96b23ad1adc9494bc2
MD5 4cc81831c2a412203bec955bb6601e30
BLAKE2b-256 903d6ba76a7198539b55cc562b9a4103af7faf9629f1101575ecf9fd427cbd52

See more details on using hashes here.

File details

Details for the file aiofiles_x-1.0.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: aiofiles_x-1.0.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 99.6 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiofiles_x-1.0.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 667b0809e0152432e0a6f02c0248d4c3c2968e6e46f7f11770f7a9bf78f556f8
MD5 5e1d2793cf074ecb5bc579a791306f4d
BLAKE2b-256 2ace8d44cd9d520d4f1f17aae95768f99427d8904535c465af8c0857fa45d160

See more details on using hashes here.

File details

Details for the file aiofiles_x-1.0.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for aiofiles_x-1.0.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0b222039d8573dfd8c65d4116086290873b59d12bf385eccb0450264d56386e9
MD5 077f6bdaf1745e8cccb22233daf5efad
BLAKE2b-256 7b289a7e4b0b52cf9de2879f0bfe153f701dc24696ea9b547ebee71d7c31704b

See more details on using hashes here.

File details

Details for the file aiofiles_x-1.0.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for aiofiles_x-1.0.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 680027b469342b06799baac9bbc3816af67917348df2e180d768ea44cbc3df2e
MD5 c6a3a17bc26a633052c6f6f347afb08a
BLAKE2b-256 4c69343ecd75a2194fd316f82109f5ff3b73abaa2c8a09c8f9ca8b418f71e61c

See more details on using hashes here.

File details

Details for the file aiofiles_x-1.0.2-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for aiofiles_x-1.0.2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f66f8b6dfa617a9b1430a651f31b128f0db3f1082de072b7c3989600aef90a7e
MD5 0bc1ecc913495642265c08eb45db97df
BLAKE2b-256 1372b841a536a5a6cc9996801678f9d2176d2235c3d052f206d338f0171325e4

See more details on using hashes here.

File details

Details for the file aiofiles_x-1.0.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: aiofiles_x-1.0.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 100.6 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiofiles_x-1.0.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4bb5c0241411c6fd842d41bb2ea0c6712dec0eb57f70b6b1c12e1dd94366a422
MD5 b8e9dc5531187108f80c30e99649671a
BLAKE2b-256 06a491265ac0407c99ef533813da856404b5783ed44017d4cb79d23093051d4e

See more details on using hashes here.

File details

Details for the file aiofiles_x-1.0.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for aiofiles_x-1.0.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c17314749e8e76acacf683f2cd0c378d96cfe6139f4dce20b2bace02e477623a
MD5 413b328e97b62f6b3f0de9ecdd0d0fd6
BLAKE2b-256 0215272804ed5c3cbe5c7613836b657d2a1f2f3d7cb8d14e627f544abfcfea0d

See more details on using hashes here.

File details

Details for the file aiofiles_x-1.0.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for aiofiles_x-1.0.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eecc9652b52e6de8a126a15d8a0bc57d5814571f5984212da29bbd657fe9c012
MD5 3237e3ee2660eb6563a4080434b1ae75
BLAKE2b-256 21d2832cba97002c8746ca81d2553c7a2e064cfc28b5dfbdd70c23bb6331473b

See more details on using hashes here.

File details

Details for the file aiofiles_x-1.0.2-cp311-cp311-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for aiofiles_x-1.0.2-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 776e2b351aa5f22700ac7d3123c63fd12dc73194187ffad4512277a7f2accaf7
MD5 3bedf9ccd677c2d55f45f3d1cee43429
BLAKE2b-256 242f69b04be0d7fc7a762553ba7ae941246d0f661cdd6ab9fe06f2944ded29d8

See more details on using hashes here.

File details

Details for the file aiofiles_x-1.0.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: aiofiles_x-1.0.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 99.2 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiofiles_x-1.0.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 025db08cc646b1b9e5d50c8b514c546c387c2819aa322ac2901fe40dbc08ed30
MD5 e04340073f6d01b9577301d15ffe6b62
BLAKE2b-256 cafebf13c1fb385106e160d8a8efc30c680d5e7e0cd94662cc457984dc14bdfb

See more details on using hashes here.

File details

Details for the file aiofiles_x-1.0.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for aiofiles_x-1.0.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 51035b8312ad2f8d4f548970258b4a9760bd17c980bd325411d4a1bfd9d354fb
MD5 4ac37d103088dad2512532e6c2e4036b
BLAKE2b-256 dc6463cb8faad9c1eed3a1ba34ac8e777f95e69d8d40080347345189bb3ce813

See more details on using hashes here.

File details

Details for the file aiofiles_x-1.0.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for aiofiles_x-1.0.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e86929a17f336f4c71ce3fd470be0100e8e92f17bf55dc6adbce64a04b0e7792
MD5 66fa3addfb8a06f73d4fe2453877b115
BLAKE2b-256 927f477aa0070ae726ba44213cdda3f77428649bfa5d8f51e189f866ee57f938

See more details on using hashes here.

File details

Details for the file aiofiles_x-1.0.2-cp310-cp310-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for aiofiles_x-1.0.2-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8a265f0a2167faa7a8ddb788cdc57d0aec3659ee703efb0e743c05c25fa31763
MD5 70b77fed7d157edce2b92101e12d6530
BLAKE2b-256 01ffe0c7fd6b84125410eab196763a7c6eb56efcf42bcb85c88bfb1a970b209c

See more details on using hashes here.

Supported by

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