cythonpowered


Namecythonpowered JSON
Version 0.1.10 PyPI version JSON
download
home_pagehttps://github.com/lucian-croitoru/cythonpowered
SummaryCython-powered replacements for popular Python functions. And more.
upload_time2024-10-08 20:44:49
maintainerNone
docs_urlNone
authorLucian Croitoru
requires_pythonNone
licenseGNU GPLv3
keywords python cython random performance
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Cython-powered replacements for popular Python functions. And more.

`cythonpowered` is a library containing **replacements** for various `Python` functions,
that are generated with `Cython` and **compiled at setup**, intended to provide **performance gains** for developers.

Some functions are **drop-in replacements**, others are provided to **enhance** certain usages of the respective functions.

## Installation
`pip install cythonpowered`

## Usage
Simply **import** the desired function and use it in your `Python` code.

Run `cythonpowered --list` to view all available functions and their `Python` conunterparts.
#### Currently available functions:
```
               _   _                                                      _ 
     ___ _   _| |_| |__   ___  _ __  _ __   _____      _____ _ __ ___  __| |
    / __| | | | __| '_ \ / _ \| '_ \| '_ \ / _ \ \ /\ / / _ \ '__/ _ \/ _` |
   | (__| |_| | |_| | | | (_) | | | | |_) | (_) \ V  V /  __/ | |  __/ (_| |
    \___|\__, |\__|_| |_|\___/|_| |_| .__/ \___/ \_/\_/ \___|_|  \___|\__,_|
         |___/                      |_|                                     
                                                                  ver. 0.1.10

+---+--------------------------------+----------------------------+-----------------------------------------------------------------------+
| # | [cythonpowered] function       | Replaces [Python] function | Usage / details                                                       |
+---+--------------------------------+----------------------------+-----------------------------------------------------------------------+
| 1 | cythonpowered.random.random    | random.random              | Drop-in replacement                                                   |
| 2 | cythonpowered.random.n_random  | random.random              | n_random(k) is equivalent to [random() for i in range(k)]             |
| 3 | cythonpowered.random.randint   | random.randint             | Drop-in replacement                                                   |
| 4 | cythonpowered.random.n_randint | random.randint             | n_randint(a, b, k) is equivalent to [randint(a, b) for i in range(k)] |
| 5 | cythonpowered.random.uniform   | random.uniform             | Drop-in replacement                                                   |
| 6 | cythonpowered.random.n_uniform | random.uniform             | n_uniform(a, b, k) is equivalent to [uniform(a, b) for i in range(k)] |
| 7 | cythonpowered.random.choice    | random.choice              | Drop-in replacement                                                   |
| 8 | cythonpowered.random.choices   | random.choices             | Drop-in replacement, only supports the 'k' keyword argument           |
+---+--------------------------------+----------------------------+-----------------------------------------------------------------------+
```

## Benchmark
Run `cythonpowered --benchmark` o view the performance gains **on your system** for all `cythonpowered` functions, compared to their `Python` counterparts.
#### Example benchmark output:
```
               _   _                                                      _ 
     ___ _   _| |_| |__   ___  _ __  _ __   _____      _____ _ __ ___  __| |
    / __| | | | __| '_ \ / _ \| '_ \| '_ \ / _ \ \ /\ / / _ \ '__/ _ \/ _` |
   | (__| |_| | |_| | | | (_) | | | | |_) | (_) \ V  V /  __/ | |  __/ (_| |
    \___|\__, |\__|_| |_|\___/|_| |_| .__/ \___/ \_/\_/ \___|_|  \___|\__,_|
         |___/                      |_|                                     
                                                                  ver. 0.1.10

CPU model:             11th Gen Intel(R) Core(TM) i7-11370H @ 3.30GHz
CPU base frequency:    3.3000 GHz
CPU cores:             4
CPU threads:           4
Architecture:          x86_64
Memory (RAM):          15.31 GB
Operating System:      Linux 6.8.0-45-generic
Python version:        3.10.12
C compiler:            GCC 11.4.0

================================================================================
Running benchmark for the [cythonpowered.random] module (5 benchmarks)...
================================================================================
Comparing [random.random] with [cythonpowered.random.random] and [cythonpowered.random.n_random]... 100.00%
Comparing [random.randint] with [cythonpowered.random.randint] and [cythonpowered.random.n_randint]... 100.00%
Comparing [random.uniform] with [cythonpowered.random.uniform] and [cythonpowered.random.n_uniform]... 100.00%
Comparing [random.choice] with [cythonpowered.random.choice]... 100.00%
Comparing [random.choices] with [cythonpowered.random.choices]... 100.00%
+--------------------------------+-----------------+-----------------------+--------------------+--------------------+-------------------+
|         Function name          |   No. of runs   |   Execution time (s)  |    Time factor     |    Speed factor    | Avg. speed factor |
+--------------------------------+-----------------+-----------------------+--------------------+--------------------+-------------------+
|     [Python] random.random     | [10K, 100K, 1M] | [0.0007, 0.006, 0.06] |        1.00        |        1.00        |        1.00       |
|  cythonpowered.random.random   | [10K, 100K, 1M] | [0.0006, 0.006, 0.06] | [0.91, 0.95, 0.97] | [1.10, 1.05, 1.03] |        1.06       |
| cythonpowered.random.n_random  | [10K, 100K, 1M] | [0.0002, 0.002, 0.02] | [0.29, 0.32, 0.29] | [3.45, 3.16, 3.47] |        3.36       |
+--------------------------------+-----------------+-----------------------+--------------------+--------------------+-------------------+
|    [Python] random.randint     | [10K, 100K, 1M] | [0.0044, 0.043, 0.43] |        1.00        |        1.00        |        1.00       |
|  cythonpowered.random.randint  | [10K, 100K, 1M] | [0.0007, 0.008, 0.08] | [0.16, 0.18, 0.18] | [6.15, 5.65, 5.46] |        5.75       |
| cythonpowered.random.n_randint | [10K, 100K, 1M] | [0.0002, 0.003, 0.03] | [0.04, 0.07, 0.07] | [23.1, 14.7, 15.1] |        17.6       |
+--------------------------------+-----------------+-----------------------+--------------------+--------------------+-------------------+
|    [Python] random.uniform     | [10K, 100K, 1M] | [0.0015, 0.014, 0.15] |        1.00        |        1.00        |        1.00       |
|  cythonpowered.random.uniform  | [10K, 100K, 1M] | [0.0006, 0.007, 0.07] | [0.41, 0.46, 0.45] | [2.44, 2.19, 2.23] |        2.29       |
| cythonpowered.random.n_uniform | [10K, 100K, 1M] | [0.0001, 0.002, 0.02] | [0.07, 0.13, 0.11] | [14.2, 7.79, 8.74] |        10.3       |
+--------------------------------+-----------------+-----------------------+--------------------+--------------------+-------------------+
|     [Python] random.choice     | [10K, 100K, 1M] | [0.0033, 0.028, 0.28] |        1.00        |        1.00        |        1.00       |
|  cythonpowered.random.choice   | [10K, 100K, 1M] | [0.0006, 0.006, 0.06] | [0.18, 0.21, 0.21] | [5.51, 4.80, 4.71] |        5.01       |
+--------------------------------+-----------------+-----------------------+--------------------+--------------------+-------------------+
|    [Python] random.choices     | [1K, 10K, 100K] | [0.0080, 0.074, 0.75] |        1.00        |        1.00        |        1.00       |
|  cythonpowered.random.choices  | [1K, 10K, 100K] | [0.0032, 0.035, 0.39] | [0.40, 0.47, 0.52] | [2.48, 2.13, 1.94] |        2.18       |
+--------------------------------+-----------------+-----------------------+--------------------+--------------------+-------------------+
```
---


# CHANGELOG

### 0.1.10 - 2024-10-08
- Added the `cythonpowered --list` command
- Added initial documentation
- Various internal tweaks

### 0.1.9 - 2024-09-29
- Bugfix in retrieveing system information for benchmark

### 0.1.8 - 2024-09-29
- Bugfix in setup
- Temporarily disabled `-fopenmp` parameter until making more thorough troubleshooting for `arm46` arch

### 0.1.7 - 2024-09-28
- Pinned versions of `setuptools` and `wheel`

### 0.1.6 - 2024-09-28
- Used `prettytable` for benchmark output (`cythonpowered --benchmark`) 

### 0.1.5 - 2024-09-23
- Bugfix in setup

### 0.1.4 - 2024-09-23
- Added the `cythonpowered` CLI script as an entrypoint for all utils and scripts
- Deprecated the `cythonpowered-benchmark` script

### 0.1.3 - 2024-09-22
- Bugfix in Cython preinstallation

### 0.1.2 - 2024-09-22
- Added MANIFEST.in
- Ensured markdown project description

### 0.1.1 - 2024-09-22
- Bugfix in setup

### 0.1.0 - 2024-09-22
- Added the `cythonpowered-benchmark` script
- Development updates

### 0.0.3 - 2024-09-10
- Update requirements

### 0.0.2 - 2024-09-10
- Bugfix in setup

### 0.0.1 - 2024-09-10
- First release
- Includes the `cythonpowered.random` module

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/lucian-croitoru/cythonpowered",
    "name": "cythonpowered",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "python, cython, random, performance",
    "author": "Lucian Croitoru",
    "author_email": "lucianalexandru.croitoru@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c9/eb/76fd9a6bd6b0aa6347eb550f8420354445d052184ce1772cfe8767ba51c7/cythonpowered-0.1.10.tar.gz",
    "platform": null,
    "description": "# Cython-powered replacements for popular Python functions. And more.\n\n`cythonpowered` is a library containing **replacements** for various `Python` functions,\nthat are generated with `Cython` and **compiled at setup**, intended to provide **performance gains** for developers.\n\nSome functions are **drop-in replacements**, others are provided to **enhance** certain usages of the respective functions.\n\n## Installation\n`pip install cythonpowered`\n\n## Usage\nSimply **import** the desired function and use it in your `Python` code.\n\nRun `cythonpowered --list` to view all available functions and their `Python` conunterparts.\n#### Currently available functions:\n```\n               _   _                                                      _ \n     ___ _   _| |_| |__   ___  _ __  _ __   _____      _____ _ __ ___  __| |\n    / __| | | | __| '_ \\ / _ \\| '_ \\| '_ \\ / _ \\ \\ /\\ / / _ \\ '__/ _ \\/ _` |\n   | (__| |_| | |_| | | | (_) | | | | |_) | (_) \\ V  V /  __/ | |  __/ (_| |\n    \\___|\\__, |\\__|_| |_|\\___/|_| |_| .__/ \\___/ \\_/\\_/ \\___|_|  \\___|\\__,_|\n         |___/                      |_|                                     \n                                                                  ver. 0.1.10\n\n+---+--------------------------------+----------------------------+-----------------------------------------------------------------------+\n| # | [cythonpowered] function       | Replaces [Python] function | Usage / details                                                       |\n+---+--------------------------------+----------------------------+-----------------------------------------------------------------------+\n| 1 | cythonpowered.random.random    | random.random              | Drop-in replacement                                                   |\n| 2 | cythonpowered.random.n_random  | random.random              | n_random(k) is equivalent to [random() for i in range(k)]             |\n| 3 | cythonpowered.random.randint   | random.randint             | Drop-in replacement                                                   |\n| 4 | cythonpowered.random.n_randint | random.randint             | n_randint(a, b, k) is equivalent to [randint(a, b) for i in range(k)] |\n| 5 | cythonpowered.random.uniform   | random.uniform             | Drop-in replacement                                                   |\n| 6 | cythonpowered.random.n_uniform | random.uniform             | n_uniform(a, b, k) is equivalent to [uniform(a, b) for i in range(k)] |\n| 7 | cythonpowered.random.choice    | random.choice              | Drop-in replacement                                                   |\n| 8 | cythonpowered.random.choices   | random.choices             | Drop-in replacement, only supports the 'k' keyword argument           |\n+---+--------------------------------+----------------------------+-----------------------------------------------------------------------+\n```\n\n## Benchmark\nRun `cythonpowered --benchmark` o view the performance gains **on your system** for all `cythonpowered` functions, compared to their `Python` counterparts.\n#### Example benchmark output:\n```\n               _   _                                                      _ \n     ___ _   _| |_| |__   ___  _ __  _ __   _____      _____ _ __ ___  __| |\n    / __| | | | __| '_ \\ / _ \\| '_ \\| '_ \\ / _ \\ \\ /\\ / / _ \\ '__/ _ \\/ _` |\n   | (__| |_| | |_| | | | (_) | | | | |_) | (_) \\ V  V /  __/ | |  __/ (_| |\n    \\___|\\__, |\\__|_| |_|\\___/|_| |_| .__/ \\___/ \\_/\\_/ \\___|_|  \\___|\\__,_|\n         |___/                      |_|                                     \n                                                                  ver. 0.1.10\n\nCPU model:             11th Gen Intel(R) Core(TM) i7-11370H @ 3.30GHz\nCPU base frequency:    3.3000 GHz\nCPU cores:             4\nCPU threads:           4\nArchitecture:          x86_64\nMemory (RAM):          15.31 GB\nOperating System:      Linux 6.8.0-45-generic\nPython version:        3.10.12\nC compiler:            GCC 11.4.0\n\n================================================================================\nRunning benchmark for the [cythonpowered.random] module (5 benchmarks)...\n================================================================================\nComparing [random.random] with [cythonpowered.random.random] and [cythonpowered.random.n_random]... 100.00%\nComparing [random.randint] with [cythonpowered.random.randint] and [cythonpowered.random.n_randint]... 100.00%\nComparing [random.uniform] with [cythonpowered.random.uniform] and [cythonpowered.random.n_uniform]... 100.00%\nComparing [random.choice] with [cythonpowered.random.choice]... 100.00%\nComparing [random.choices] with [cythonpowered.random.choices]... 100.00%\n+--------------------------------+-----------------+-----------------------+--------------------+--------------------+-------------------+\n|         Function name          |   No. of runs   |   Execution time (s)  |    Time factor     |    Speed factor    | Avg. speed factor |\n+--------------------------------+-----------------+-----------------------+--------------------+--------------------+-------------------+\n|     [Python] random.random     | [10K, 100K, 1M] | [0.0007, 0.006, 0.06] |        1.00        |        1.00        |        1.00       |\n|  cythonpowered.random.random   | [10K, 100K, 1M] | [0.0006, 0.006, 0.06] | [0.91, 0.95, 0.97] | [1.10, 1.05, 1.03] |        1.06       |\n| cythonpowered.random.n_random  | [10K, 100K, 1M] | [0.0002, 0.002, 0.02] | [0.29, 0.32, 0.29] | [3.45, 3.16, 3.47] |        3.36       |\n+--------------------------------+-----------------+-----------------------+--------------------+--------------------+-------------------+\n|    [Python] random.randint     | [10K, 100K, 1M] | [0.0044, 0.043, 0.43] |        1.00        |        1.00        |        1.00       |\n|  cythonpowered.random.randint  | [10K, 100K, 1M] | [0.0007, 0.008, 0.08] | [0.16, 0.18, 0.18] | [6.15, 5.65, 5.46] |        5.75       |\n| cythonpowered.random.n_randint | [10K, 100K, 1M] | [0.0002, 0.003, 0.03] | [0.04, 0.07, 0.07] | [23.1, 14.7, 15.1] |        17.6       |\n+--------------------------------+-----------------+-----------------------+--------------------+--------------------+-------------------+\n|    [Python] random.uniform     | [10K, 100K, 1M] | [0.0015, 0.014, 0.15] |        1.00        |        1.00        |        1.00       |\n|  cythonpowered.random.uniform  | [10K, 100K, 1M] | [0.0006, 0.007, 0.07] | [0.41, 0.46, 0.45] | [2.44, 2.19, 2.23] |        2.29       |\n| cythonpowered.random.n_uniform | [10K, 100K, 1M] | [0.0001, 0.002, 0.02] | [0.07, 0.13, 0.11] | [14.2, 7.79, 8.74] |        10.3       |\n+--------------------------------+-----------------+-----------------------+--------------------+--------------------+-------------------+\n|     [Python] random.choice     | [10K, 100K, 1M] | [0.0033, 0.028, 0.28] |        1.00        |        1.00        |        1.00       |\n|  cythonpowered.random.choice   | [10K, 100K, 1M] | [0.0006, 0.006, 0.06] | [0.18, 0.21, 0.21] | [5.51, 4.80, 4.71] |        5.01       |\n+--------------------------------+-----------------+-----------------------+--------------------+--------------------+-------------------+\n|    [Python] random.choices     | [1K, 10K, 100K] | [0.0080, 0.074, 0.75] |        1.00        |        1.00        |        1.00       |\n|  cythonpowered.random.choices  | [1K, 10K, 100K] | [0.0032, 0.035, 0.39] | [0.40, 0.47, 0.52] | [2.48, 2.13, 1.94] |        2.18       |\n+--------------------------------+-----------------+-----------------------+--------------------+--------------------+-------------------+\n```\n---\n\n\n# CHANGELOG\n\n### 0.1.10 - 2024-10-08\n- Added the `cythonpowered --list` command\n- Added initial documentation\n- Various internal tweaks\n\n### 0.1.9 - 2024-09-29\n- Bugfix in retrieveing system information for benchmark\n\n### 0.1.8 - 2024-09-29\n- Bugfix in setup\n- Temporarily disabled `-fopenmp` parameter until making more thorough troubleshooting for `arm46` arch\n\n### 0.1.7 - 2024-09-28\n- Pinned versions of `setuptools` and `wheel`\n\n### 0.1.6 - 2024-09-28\n- Used `prettytable` for benchmark output (`cythonpowered --benchmark`) \n\n### 0.1.5 - 2024-09-23\n- Bugfix in setup\n\n### 0.1.4 - 2024-09-23\n- Added the `cythonpowered` CLI script as an entrypoint for all utils and scripts\n- Deprecated the `cythonpowered-benchmark` script\n\n### 0.1.3 - 2024-09-22\n- Bugfix in Cython preinstallation\n\n### 0.1.2 - 2024-09-22\n- Added MANIFEST.in\n- Ensured markdown project description\n\n### 0.1.1 - 2024-09-22\n- Bugfix in setup\n\n### 0.1.0 - 2024-09-22\n- Added the `cythonpowered-benchmark` script\n- Development updates\n\n### 0.0.3 - 2024-09-10\n- Update requirements\n\n### 0.0.2 - 2024-09-10\n- Bugfix in setup\n\n### 0.0.1 - 2024-09-10\n- First release\n- Includes the `cythonpowered.random` module\n",
    "bugtrack_url": null,
    "license": "GNU GPLv3",
    "summary": "Cython-powered replacements for popular Python functions. And more.",
    "version": "0.1.10",
    "project_urls": {
        "Homepage": "https://github.com/lucian-croitoru/cythonpowered"
    },
    "split_keywords": [
        "python",
        " cython",
        " random",
        " performance"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c9eb76fd9a6bd6b0aa6347eb550f8420354445d052184ce1772cfe8767ba51c7",
                "md5": "228fe5c2f47bcbeaacd25d286b842aa2",
                "sha256": "6ff16db5d33d0a91b2f6de75845a660a19214364811b920fc04c72cc9c5a9ad6"
            },
            "downloads": -1,
            "filename": "cythonpowered-0.1.10.tar.gz",
            "has_sig": false,
            "md5_digest": "228fe5c2f47bcbeaacd25d286b842aa2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 73390,
            "upload_time": "2024-10-08T20:44:49",
            "upload_time_iso_8601": "2024-10-08T20:44:49.929858Z",
            "url": "https://files.pythonhosted.org/packages/c9/eb/76fd9a6bd6b0aa6347eb550f8420354445d052184ce1772cfe8767ba51c7/cythonpowered-0.1.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-08 20:44:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lucian-croitoru",
    "github_project": "cythonpowered",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "cythonpowered"
}
        
Elapsed time: 1.78523s