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.4/aiofiles_x-1.0.4.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(), readall(), read1(), readinto(), readline(), readlines()
  • write(), 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.4.tar.gz (40.3 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.4-cp312-cp312-win_amd64.whl (101.6 kB view details)

Uploaded CPython 3.12Windows x86-64

aiofiles_x-1.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (168.7 kB view details)

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

aiofiles_x-1.0.4-cp312-cp312-macosx_11_0_arm64.whl (149.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

aiofiles_x-1.0.4-cp312-cp312-macosx_10_13_x86_64.whl (146.5 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

aiofiles_x-1.0.4-cp311-cp311-win_amd64.whl (102.6 kB view details)

Uploaded CPython 3.11Windows x86-64

aiofiles_x-1.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (169.0 kB view details)

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

aiofiles_x-1.0.4-cp311-cp311-macosx_11_0_arm64.whl (150.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

aiofiles_x-1.0.4-cp311-cp311-macosx_10_13_x86_64.whl (147.6 kB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

aiofiles_x-1.0.4-cp310-cp310-win_amd64.whl (101.2 kB view details)

Uploaded CPython 3.10Windows x86-64

aiofiles_x-1.0.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (168.2 kB view details)

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

aiofiles_x-1.0.4-cp310-cp310-macosx_11_0_arm64.whl (149.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

aiofiles_x-1.0.4-cp310-cp310-macosx_10_13_x86_64.whl (146.7 kB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: aiofiles_x-1.0.4.tar.gz
  • Upload date:
  • Size: 40.3 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.4.tar.gz
Algorithm Hash digest
SHA256 dbd9b90ad75808c743cb474e482e2870cf6829047cd3aa3818323fb919b7002d
MD5 232ddabf7ed039667873b9f9b0b0b53f
BLAKE2b-256 cf1d714711dba41bd51c76d4994faf4014ad7fd9deac14a247042e1fd1a3939f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiofiles_x-1.0.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 101.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.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cd68a1d89aab47dc343de7b0a75127a83146b3c1085b3b7f407f0e7ea609cad7
MD5 3776502ba3ec71b025c71ac7a14118d6
BLAKE2b-256 0c580bd51b0c7b1b61f1561ac55d85f03d859c5560724104e9d05d67c3f9fbf5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aiofiles_x-1.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8bfc3f5366396af437ba158170d7c09962501856ce828595c0cb3376aa30c889
MD5 fece4faf97a2c1fc9c4acbaa06fd12ad
BLAKE2b-256 677ca87dd6dc091765111acca32a1001a2de961545f34987c91475d7b41a75d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aiofiles_x-1.0.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d20778d09a796a0f5de7e9b9bd3f1dd9f63fa2845d08c379087bbde12b4a59eb
MD5 1fdf9ca621c595a01a50ed1eb5c4e7dd
BLAKE2b-256 903c97b7481006da0e3b9125bc2a2ac47581a2076da4a19ad90eef9ec258f3e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aiofiles_x-1.0.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b2f2084b648a2a0ff3d41d171de4bfa5176db82fd0366e6260f3a6e01e8635b3
MD5 3bed4fbea3dafc313c748ad5820e4775
BLAKE2b-256 e78336af22abf68f7789c74272effd1eb01d44a5efe5ff06622b86d30c6cf26b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiofiles_x-1.0.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 102.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.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8f0e70ca7a0f22c3aca48a96abdc66cbd0dbe273918b373a578c067c75e4487d
MD5 7fb26ba897436829d5b0efc5abd91c4b
BLAKE2b-256 ec96b02d289fbaa4774eed793a00817288ba1271cf8d41971e06d43162dda1c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aiofiles_x-1.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5bb2bd89c7b49a92a129782b880526455eb232fb8853a7384758ac09d71e80be
MD5 a6e221d410f9347348e40b8a3aafaa18
BLAKE2b-256 677576054a3a0756f3fa21ab38aa36deaf052a61f4cd4d4f966b2d361ea798ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aiofiles_x-1.0.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7634e26e58a90e367e10000ae441dfe80af916e0190a365fded576ed762a7b67
MD5 ed26e84b42d3baeb8578bdc6127dcccb
BLAKE2b-256 bbd15d506522c65176fb73f946d606614b409a4bbef46b9888126288cffb069e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aiofiles_x-1.0.4-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8afda2f0a1b9b39624e54af3ef7e465ff26b74956ac138945874708eb7e2b469
MD5 98ee80ed6587394e9301040ee4414573
BLAKE2b-256 73934978621dd6043c40ebf8af8f17cf6b75f8a12575fbd59820f931805336cd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiofiles_x-1.0.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 101.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.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 59034a18b5bee803d4ffea7b1562a3936e2f0f2ebaf4bab7f91f14f7a2657f07
MD5 8b4544b92d349ab1881df94a56c8a588
BLAKE2b-256 60929174a76c2efc96c36db5c43cbd7f24dc740c86a65f1acb52138ab32234f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aiofiles_x-1.0.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 da0b8882923e1aed37dc015b16337033eddf1fde3d250c2dcb7b7910931c7167
MD5 a7bb7acdb53be3c77ebd6d1b5ff14503
BLAKE2b-256 40349c033aea369436fb805afd00b48ac34f143c05905fbf169197c749a82627

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aiofiles_x-1.0.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a12303678f6460e553a2fee5bb763e419e7ad9ca539e4d6950218967ad8c3112
MD5 82a630a3d4e7b3e1c0d9f1a1a6956fea
BLAKE2b-256 b2d69c195068f413137ca44a1e5140bb954ebaa2e421dbc447af814b789a482e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aiofiles_x-1.0.4-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5b3a08d6d12a7fa916b88a8ac4632b379d98245f0c29da96624f9b45ba9e3319
MD5 12b0fa769482d05c320598c858ab4110
BLAKE2b-256 0ab961b2ffb660c1a1af646051fd1f0f3ec547f3667847b4280e24ae40f5b1e1

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