Skip to main content

PyFastUtil provides fast, fully Python-compatible data structures along with bindings to low-level interfaces.

Project description

English | 简体中文

PyFastUtil

Project Mascot

Make Python Fast Again

License Issues Version Build

Introduction

PyFastUtil is a high-performance utility library for Python, inspired by Java's FastUtil library. However, PyFastUtil is NOT a Python binding for FastUtil. It is a library built from the ground up, designed to bring C-like efficiency and functionality to CPython.

Features

  • Implements all corresponding Python data structure interfaces while significantly improving performance through targeted optimizations. Users can choose the most suitable data structure type based on their needs.
  • Fully implemented in C/C++ with hardware-level optimizations such as SIMD, aiming to maximize the performance of data structures.
  • Provides efficient Python bindings for some C APIs, allowing advanced users to perform "unsafe" low-level operations.
  • Enables inline assembly, allowing advanced users to dynamically generate, invoke, and destroy C functions at runtime.

Benchmark

Note: For extremely fast (O(1)) operations (e.g., pop, extend), PyFastUtil's performance may be slightly inferior to Python's native implementation due to the unavoidable overhead of calling C extensions from CPython. We are actively working to optimize this.

CPU: AMD Ryzen 7 5700G (AVX2)

Windows 11 23H2, Python 3.12, MSVC 19.41.34120

Type-Specialized List (e.g., IntArrayList)

Preparing data...
---Python list & IntArrayList Benchmark---
Batch size: 10000
Repeat: 3

Python list init time: 0.02 ms
PyFastUtil IntArrayList init time: 0.08 ms
PyFastUtil speed of Python list (init): 29.788 %

Python list copy time: 0.02 ms
PyFastUtil IntArrayList copy time: 0.00 ms
PyFastUtil speed of Python list (copy): 766.102 %

Python list to_python time: 0.02 ms
PyFastUtil IntArrayList to_python time: 0.27 ms
PyFastUtil speed of Python list (to_python): 5.821 %

Python list sequential_access time: 0.00 ms
PyFastUtil IntArrayList sequential_access time: 0.00 ms
PyFastUtil speed of Python list (sequential_access): 126.667 %

Python list random_access time: 0.39 ms
PyFastUtil IntArrayList random_access time: 0.62 ms
PyFastUtil speed of Python list (random_access): 62.423 %

Python list sort time: 1.29 ms
PyFastUtil IntArrayList sort time: 0.04 ms
PyFastUtil speed of Python list (sort): 3344.483 %

Python list append time: 0.23 ms
PyFastUtil IntArrayList append time: 0.32 ms
PyFastUtil speed of Python list (append): 72.517 %

Python list insert time: 70.74 ms
PyFastUtil IntArrayList insert time: 10.93 ms
PyFastUtil speed of Python list (insert): 647.349 %

Python list pop time: 0.29 ms
PyFastUtil IntArrayList pop time: 0.35 ms
PyFastUtil speed of Python list (pop): 85.143 %

Python list remove time: 5.50 ms
PyFastUtil IntArrayList remove time: 2.54 ms
PyFastUtil speed of Python list (remove): 216.749 %

Python list contains time: 258.02 ms
PyFastUtil IntArrayList contains time: 2.61 ms
PyFastUtil speed of Python list (contains): 9896.599 %

Python list index time: 438.12 ms
PyFastUtil IntArrayList index time: 3.77 ms
PyFastUtil speed of Python list (index): 11618.038 %

Python list extend time: 0.08 ms
PyFastUtil IntArrayList extend time: 0.14 ms
PyFastUtil speed of Python list (extend): 58.433 %

Python list reverse time: 0.00 ms
PyFastUtil IntArrayList reverse time: 0.00 ms
PyFastUtil speed of Python list (reverse): 378.948 %


Avg speed of PyFastUtil compared to Python list: 1950.647 %

Generic Type List (e.g., ObjectArrayList)

Preparing data...
---Python list & ObjectArrayList Benchmark---
Batch size: 10000
Repeat: 3

Python list init time: 0.06 ms
PyFastUtil ObjectArrayList init time: 0.05 ms
PyFastUtil speed of Python list (init): 129.484 %

Python list copy time: 0.07 ms
PyFastUtil ObjectArrayList copy time: 0.03 ms
PyFastUtil speed of Python list (copy): 268.376 %

Python list to_python time: 0.03 ms
PyFastUtil ObjectArrayList to_python time: 0.03 ms
PyFastUtil speed of Python list (to_python): 99.325 %

Python list sequential_access time: 0.00 ms
PyFastUtil ObjectArrayList sequential_access time: 0.00 ms
PyFastUtil speed of Python list (sequential_access): 139.130 %

Python list random_access time: 0.22 ms
PyFastUtil ObjectArrayList random_access time: 0.31 ms
PyFastUtil speed of Python list (random_access): 71.053 %

Python list sort time: 1039.91 ms
PyFastUtil ObjectArrayList sort time: 1003.55 ms
PyFastUtil speed of Python list (sort): 103.623 %

Python list append time: 0.27 ms
PyFastUtil ObjectArrayList append time: 0.33 ms
PyFastUtil speed of Python list (append): 81.091 %

Python list insert time: 72.43 ms
PyFastUtil ObjectArrayList insert time: 20.82 ms
PyFastUtil speed of Python list (insert): 347.893 %

Python list pop time: 0.36 ms
PyFastUtil ObjectArrayList pop time: 0.27 ms
PyFastUtil speed of Python list (pop): 130.323 %

Python list remove time: 5.17 ms
PyFastUtil ObjectArrayList remove time: 5.17 ms
PyFastUtil speed of Python list (remove): 100.102 %

Python list contains time: 665.64 ms
PyFastUtil ObjectArrayList contains time: 3.77 ms
PyFastUtil speed of Python list (contains): 17634.553 %

Python list index time: 985.46 ms
PyFastUtil ObjectArrayList index time: 6.80 ms
PyFastUtil speed of Python list (index): 14501.919 %

Python list extend time: 0.08 ms
PyFastUtil ObjectArrayList extend time: 0.12 ms
PyFastUtil speed of Python list (extend): 73.264 %

Python list reverse time: 0.00 ms
PyFastUtil ObjectArrayList reverse time: 0.00 ms
PyFastUtil speed of Python list (reverse): 106.000 %


Avg speed of PyFastUtil compared to Python list: 2413.296 %

Installation

Install PyFastUtil from PyPI:

pip install PyFastUtil

Or, build from source

If you'd like to build the project from source, follow these steps:

  1. Clone the repository:

    git clone https://github.com/yourusername/PyFastUtil.git
    cd PyFastUtil
    
  2. Build the project:

    • On Windows:
      ./build.cmd
      
    • On Linux/macOS:
      ./build.sh
      

License

This project is licensed under the Apache License 2.0. For more details, see the LICENSE file.

Roadmap

  • Implement int, float, and double ArrayList and LinkedList.
  • Add Numpy support.
  • Provide bindings for SIMD utility functions.
  • Provide raw AVX512 bindings.
  • Perform comprehensive testing and benchmarking.
  • Publish to PyPI.

Contribution

Contributions are welcome! Feel free to submit issues or pull requests. Please note that the project is in its early stages, and we greatly appreciate any feedback or suggestions.

Acknowledgements

This project is partially based on the following excellent open-source projects:

Special thanks to the contributors of these open-source projects!

The mascot image of the project was created by the artist kokola and is used with permission. You can view the original artwork on X.

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

pyfastutil-0.1.1.tar.gz (194.8 kB view details)

Uploaded Source

Built Distributions

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

PyFastUtil-0.1.1-cp313-cp313-win_amd64.whl (244.6 kB view details)

Uploaded CPython 3.13Windows x86-64

PyFastUtil-0.1.1-cp313-cp313-macosx_10_13_universal2.whl (247.7 kB view details)

Uploaded CPython 3.13macOS 10.13+ universal2 (ARM64, x86-64)

PyFastUtil-0.1.1-cp312-cp312-win_amd64.whl (244.5 kB view details)

Uploaded CPython 3.12Windows x86-64

PyFastUtil-0.1.1-cp312-cp312-macosx_10_13_universal2.whl (247.0 kB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

PyFastUtil-0.1.1-cp311-cp311-win_amd64.whl (244.7 kB view details)

Uploaded CPython 3.11Windows x86-64

PyFastUtil-0.1.1-cp311-cp311-macosx_11_0_universal2.whl (245.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ universal2 (ARM64, x86-64)

PyFastUtil-0.1.1-cp310-cp310-win_amd64.whl (244.8 kB view details)

Uploaded CPython 3.10Windows x86-64

PyFastUtil-0.1.1-cp310-cp310-macosx_11_0_universal2.whl (245.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ universal2 (ARM64, x86-64)

PyFastUtil-0.1.1-cp39-cp39-win_amd64.whl (248.3 kB view details)

Uploaded CPython 3.9Windows x86-64

PyFastUtil-0.1.1-cp39-cp39-macosx_11_0_universal2.whl (245.0 kB view details)

Uploaded CPython 3.9macOS 11.0+ universal2 (ARM64, x86-64)

File details

Details for the file pyfastutil-0.1.1.tar.gz.

File metadata

  • Download URL: pyfastutil-0.1.1.tar.gz
  • Upload date:
  • Size: 194.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pyfastutil-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5181eea2dfbcff1372ff2920763f5debde9416111534bbd328a2d5e8335eba1c
MD5 2ce97a74c328592bcaeb31be999503bc
BLAKE2b-256 ac727841ef1861e2b1cf14aa4edc17e5e7f72961054c97dfbaea9be9c8278655

See more details on using hashes here.

File details

Details for the file PyFastUtil-0.1.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: PyFastUtil-0.1.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 244.6 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for PyFastUtil-0.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b58c3732b16d6ec7afe9e8fe679d31c9e9ad71409f5b509666db4b63aefe1b10
MD5 51811aaac149e485d805263af65dbe24
BLAKE2b-256 24abc51a471c451206dce3d81bee36c0d203a8e94747f845b4352c4e2700a44d

See more details on using hashes here.

File details

Details for the file PyFastUtil-0.1.1-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for PyFastUtil-0.1.1-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 5469311743aa1dd519d53374b8c339007df0eb4d51ff9223a1d70374eedac687
MD5 20907e00e9220f1d26ad998a542c1b12
BLAKE2b-256 cb6409782d92b37fe40e4dc9b55457db74669250832acc419be1de9b10ff3334

See more details on using hashes here.

File details

Details for the file PyFastUtil-0.1.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: PyFastUtil-0.1.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 244.5 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for PyFastUtil-0.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7f44c999ccc19107ec7b9de7495bccb66ce5dc203e89d0675f2431fa166b428d
MD5 9a0e88d95c94a75de62f40e9871d09f6
BLAKE2b-256 0b56538f34405f44213590aad4b8d9b6743eba8161dab683ca36083c35a5db57

See more details on using hashes here.

File details

Details for the file PyFastUtil-0.1.1-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for PyFastUtil-0.1.1-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 8376820dc56d727b7718932bb0af95807b743ef521f5e92f8d708cbeb31542a4
MD5 d22585ccfd69f4896786dd373da7f30a
BLAKE2b-256 d6e0dc10ed6416f041471a189d404570f389f1625da95638d89a8c9b1424bcd3

See more details on using hashes here.

File details

Details for the file PyFastUtil-0.1.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: PyFastUtil-0.1.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 244.7 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for PyFastUtil-0.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0c953245e34a44eab8aa025e30a5405d54343ddf0069f0ac41c3036255880501
MD5 15f60a0ad7efb5bb91672a719d20556c
BLAKE2b-256 86367a1aadae7bb7261ef5e58aed1c09b9e16ec0dc6eaf8f77c3c487c4e709bc

See more details on using hashes here.

File details

Details for the file PyFastUtil-0.1.1-cp311-cp311-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for PyFastUtil-0.1.1-cp311-cp311-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 8d75ee7dec2efef4e698fadc4f5ba0f570b6d6543069a522222a4e51228510f0
MD5 d87ab0115b2a7cfb1b854815bd7d2d82
BLAKE2b-256 1ae55dcbc3a2c7e195d56ac82f0c3d20dc8a4674befe62ec51685e80005cb1fb

See more details on using hashes here.

File details

Details for the file PyFastUtil-0.1.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: PyFastUtil-0.1.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 244.8 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.11

File hashes

Hashes for PyFastUtil-0.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d1963f12a0de0f1a07567eb790afcffa72b06fdd37fecd7fc787088487efa4db
MD5 c49e4b8a57d7dbe6bcc756626794354d
BLAKE2b-256 c46291e75b9533ae1632901d9f9e4b848602ad5a5f621881374e9ef5b599e848

See more details on using hashes here.

File details

Details for the file PyFastUtil-0.1.1-cp310-cp310-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for PyFastUtil-0.1.1-cp310-cp310-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 2c481ae564d355a67e9f023b88168c868c497563c370706caa201ca57bfcbaf9
MD5 f4e93cc55a1ee82aa8bf3950c0ed8d6b
BLAKE2b-256 863cc955ad4245665b9ca60a42493d75ac6f80a845cd3f5263f09037c42ecf97

See more details on using hashes here.

File details

Details for the file PyFastUtil-0.1.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: PyFastUtil-0.1.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 248.3 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.13

File hashes

Hashes for PyFastUtil-0.1.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d91254785d7966d6775a0d73550e8a29fe11ba7e64616b339e814b1ca71cea15
MD5 923db21a0d41f4516c891b457ee1fdc7
BLAKE2b-256 98fd36f798973ffafd13e4a426022c838ecaf4e7ebb54712580066c9b257fd1a

See more details on using hashes here.

File details

Details for the file PyFastUtil-0.1.1-cp39-cp39-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for PyFastUtil-0.1.1-cp39-cp39-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 7a8e7fb9c34510e453c488d2d7629dcdf18b15f29f65e41bb843073f20d98b1f
MD5 84e6251387a80f700d36f997c17bf226
BLAKE2b-256 da4003f2b06e8d34d01523137a4c3c71aa8a93f200575bbe48a102b10b069df8

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