# UiuaPy
A bridge between [Uiua](https://www.uiua.org/) and [NumPy](https://numpy.org/) - enabling you to do tacit array processing in Python.
## Installation
```sh
pip install uiuapy
```
If building the source distribution, rather than installing a precompiled wheel, you will need to have [rustup](https://rustup.rs/) installed on your machine.
## Usage
```py
import uiua
print(uiua.compile('/+')([1, 2, 3]))
# 6.0
print(uiua.compile('⌕')('ab', 'abracabra'))
# [1 0 0 0 0 1 0 0 0]
```
### Flags
You can allow thread spawning either specific to a program, or specific to an invocation. Invocation flags take precedence over program flags.
```py
import numpy as np
import uiua
xs = np.linspace(0, 1, 10_000)
print(uiua.compile('/+', allow_threads=True)(xs))
# 50000.0
print(uiua.compile('/+')(xs, allow_threads=True))
# 50000.0
```
## NumPy integration
UiuaPy uses the [NumPy C-API](https://numpy.org/doc/2.1/reference/c-api/index.html) for taking in Python inputs and returning Python results.
Uiua supports 5 data-types for arrays/scalars:
|Uiua type|NumPy equivalent dtype|
|---------|----------------------|
|Num|float64|
|Byte|uint8|
|Complex|complex128|
|Char|Unicode (32-bit characters)|
|Box|object|
If you pass in a NumPy array that does not have one of the above dtypes, it will be automatically converted according to the table below:
|NumPy dtype|Converted NumPy dtype|Uiua type|
|-|-|-|
|float32|float64|Num|
|uint64|float64|Num|
|uint32|float64|Num|
|uint16|float64|Num|
|int64|float64|Num|
|int32|float64|Num|
|int16|float64|Num|
|bool|uint8|Byte|
#### Interfacing overhead
Passing a numpy array to uiua requires copying its memory (using `memcpy`/ [`std::ptr::copy_nonoverlapping`](https://doc.rust-lang.org/beta/std/ptr/fn.copy_nonoverlapping.html) in Rust). The same is true for the values returned from the Uiua computation.
If using anything other than float64, uint8, complex128 or unicode data - there are also type conversion costs to take into account.
## Development
### Dependencies
- [rustup](https://rustup.rs/)
- [uv](https://docs.astral.sh/uv/getting-started/installation/)
```sh
# Format code
uv run ruff format
cargo fmt
# Fix/report lints
uv run ruff check --fix
cargo clippy
# Run tests
uv run pytest
# Build wheels
uv build
```
Raw data
{
"_id": null,
"home_page": null,
"name": "uiuapy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "uiuapy, uiua, apl, J, kdb, numpy, pyo3, array, programming, language, vectorized",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/e2/05/4c522004df83b988555928d976f8945d223a39704b51f98abf4a46558562/uiuapy-0.2.0.tar.gz",
"platform": null,
"description": "# UiuaPy\n\nA bridge between [Uiua](https://www.uiua.org/) and [NumPy](https://numpy.org/) - enabling you to do tacit array processing in Python.\n\n## Installation\n```sh\npip install uiuapy\n```\n\nIf building the source distribution, rather than installing a precompiled wheel, you will need to have [rustup](https://rustup.rs/) installed on your machine.\n\n## Usage\n```py\nimport uiua\n\nprint(uiua.compile('/+')([1, 2, 3]))\n# 6.0\n\nprint(uiua.compile('\u2315')('ab', 'abracabra')) \n# [1 0 0 0 0 1 0 0 0]\n```\n\n### Flags\nYou can allow thread spawning either specific to a program, or specific to an invocation. Invocation flags take precedence over program flags.\n```py\nimport numpy as np\nimport uiua\n\nxs = np.linspace(0, 1, 10_000)\n\nprint(uiua.compile('/+', allow_threads=True)(xs))\n# 50000.0\n\nprint(uiua.compile('/+')(xs, allow_threads=True))\n# 50000.0\n\n```\n\n## NumPy integration\nUiuaPy uses the [NumPy C-API](https://numpy.org/doc/2.1/reference/c-api/index.html) for taking in Python inputs and returning Python results.\n\nUiua supports 5 data-types for arrays/scalars:\n\n|Uiua type|NumPy equivalent dtype|\n|---------|----------------------|\n|Num|float64|\n|Byte|uint8|\n|Complex|complex128|\n|Char|Unicode (32-bit characters)|\n|Box|object|\n\nIf you pass in a NumPy array that does not have one of the above dtypes, it will be automatically converted according to the table below:\n|NumPy dtype|Converted NumPy dtype|Uiua type|\n|-|-|-|\n|float32|float64|Num|\n|uint64|float64|Num|\n|uint32|float64|Num|\n|uint16|float64|Num|\n|int64|float64|Num|\n|int32|float64|Num|\n|int16|float64|Num|\n|bool|uint8|Byte|\n\n#### Interfacing overhead\nPassing a numpy array to uiua requires copying its memory (using `memcpy`/ [`std::ptr::copy_nonoverlapping`](https://doc.rust-lang.org/beta/std/ptr/fn.copy_nonoverlapping.html) in Rust). The same is true for the values returned from the Uiua computation.\n\nIf using anything other than float64, uint8, complex128 or unicode data - there are also type conversion costs to take into account.\n\n## Development\n\n### Dependencies\n- [rustup](https://rustup.rs/)\n- [uv](https://docs.astral.sh/uv/getting-started/installation/)\n\n```sh\n# Format code\nuv run ruff format\ncargo fmt\n\n# Fix/report lints\nuv run ruff check --fix\ncargo clippy\n\n# Run tests\nuv run pytest\n\n# Build wheels\nuv build\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Use the Uiua array programming language from Python",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/bergkvist/uiuapy",
"Repository": "https://github.com/bergkvist/uiuapy"
},
"split_keywords": [
"uiuapy",
" uiua",
" apl",
" j",
" kdb",
" numpy",
" pyo3",
" array",
" programming",
" language",
" vectorized"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "cad09bd9f3c4c209c5b1b7723b7bae9b05caef5fc4f9759e5613802224ddeded",
"md5": "b67f5c6c6f94358973c529cddefdfe89",
"sha256": "7f9915023206212b34aa02a7b0f6a04fde32dbe3b16addd4d3e5d9787b1f5e65"
},
"downloads": -1,
"filename": "uiuapy-0.2.0-cp310-cp310-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "b67f5c6c6f94358973c529cddefdfe89",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.9",
"size": 9057451,
"upload_time": "2025-08-24T23:04:50",
"upload_time_iso_8601": "2025-08-24T23:04:50.264314Z",
"url": "https://files.pythonhosted.org/packages/ca/d0/9bd9f3c4c209c5b1b7723b7bae9b05caef5fc4f9759e5613802224ddeded/uiuapy-0.2.0-cp310-cp310-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "87cdbed75b3bcb930ffe1f94bc57af0c35007e8964d57abe8bf0e7b68d0a0a3f",
"md5": "e6f40771089b13bd01b7cbaf2f2877c7",
"sha256": "5cf8ff5ab42857109b297b338328254c909ace874481239c789c6a5c7e8d9f23"
},
"downloads": -1,
"filename": "uiuapy-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "e6f40771089b13bd01b7cbaf2f2877c7",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.9",
"size": 10533888,
"upload_time": "2025-08-24T23:04:52",
"upload_time_iso_8601": "2025-08-24T23:04:52.786682Z",
"url": "https://files.pythonhosted.org/packages/87/cd/bed75b3bcb930ffe1f94bc57af0c35007e8964d57abe8bf0e7b68d0a0a3f/uiuapy-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7f45fe1e54cb9ad9ecd464603edfe06b410a4c69de4336a72b8a03cd24aafac7",
"md5": "acc639fdd95951eb377f927312250f70",
"sha256": "fbbe146cc8d82b2c9178691988760e5bd3a6dd85379e9c30af7a45e841f9057f"
},
"downloads": -1,
"filename": "uiuapy-0.2.0-cp310-cp310-win_amd64.whl",
"has_sig": false,
"md5_digest": "acc639fdd95951eb377f927312250f70",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.9",
"size": 9496898,
"upload_time": "2025-08-24T23:04:55",
"upload_time_iso_8601": "2025-08-24T23:04:55.045130Z",
"url": "https://files.pythonhosted.org/packages/7f/45/fe1e54cb9ad9ecd464603edfe06b410a4c69de4336a72b8a03cd24aafac7/uiuapy-0.2.0-cp310-cp310-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d1afdbd1b0f92d2d5bd8a102e740f7f73c7787de28fe844cb51efe445f844eed",
"md5": "a6a62d913a56a96147b0c78bc499d335",
"sha256": "3d9f8be72de33f3ec10015a75ffb87debdd1683c0cfc26b7f169a9d130110f5c"
},
"downloads": -1,
"filename": "uiuapy-0.2.0-cp311-cp311-macosx_11_0_universal2.whl",
"has_sig": false,
"md5_digest": "a6a62d913a56a96147b0c78bc499d335",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.9",
"size": 9057083,
"upload_time": "2025-08-24T23:04:57",
"upload_time_iso_8601": "2025-08-24T23:04:57.528897Z",
"url": "https://files.pythonhosted.org/packages/d1/af/dbd1b0f92d2d5bd8a102e740f7f73c7787de28fe844cb51efe445f844eed/uiuapy-0.2.0-cp311-cp311-macosx_11_0_universal2.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7eecb7ddc2fedf3318f40fafce2ad99c83903b65149edf63c61e5ae9ca1ec042",
"md5": "181826461ee2c8eef71a0207ec129ebe",
"sha256": "8df8b46e3db514cec6238915f1f96761268ad83c49409482f8e768bcb59ec5f1"
},
"downloads": -1,
"filename": "uiuapy-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "181826461ee2c8eef71a0207ec129ebe",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.9",
"size": 10534986,
"upload_time": "2025-08-24T23:04:59",
"upload_time_iso_8601": "2025-08-24T23:04:59.417589Z",
"url": "https://files.pythonhosted.org/packages/7e/ec/b7ddc2fedf3318f40fafce2ad99c83903b65149edf63c61e5ae9ca1ec042/uiuapy-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ce8ecb1f8411f5dbb479b0dbca5de4360b213f5b7a398140e73449f76591f831",
"md5": "5de0f7e9267b3cea2168177b29a5030a",
"sha256": "f024a05ffe3621ef70a4dde887a5e5349566ffb9988ca433dcb750a2c2ed19d0"
},
"downloads": -1,
"filename": "uiuapy-0.2.0-cp311-cp311-win_amd64.whl",
"has_sig": false,
"md5_digest": "5de0f7e9267b3cea2168177b29a5030a",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.9",
"size": 9496971,
"upload_time": "2025-08-24T23:05:01",
"upload_time_iso_8601": "2025-08-24T23:05:01.244134Z",
"url": "https://files.pythonhosted.org/packages/ce/8e/cb1f8411f5dbb479b0dbca5de4360b213f5b7a398140e73449f76591f831/uiuapy-0.2.0-cp311-cp311-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8f8e89d66d1fc20266281e9a8172d63a015d7fbb22088a8dd15100f8a1090a13",
"md5": "05147844ffaddc7d4329de4ee6b0eecb",
"sha256": "8dfe8b2b54aa25924db2fea94bdb152638ad89834153b207c836f11eb8dfd317"
},
"downloads": -1,
"filename": "uiuapy-0.2.0-cp312-cp312-macosx_15_0_arm64.whl",
"has_sig": false,
"md5_digest": "05147844ffaddc7d4329de4ee6b0eecb",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.9",
"size": 9054817,
"upload_time": "2025-08-24T23:05:03",
"upload_time_iso_8601": "2025-08-24T23:05:03.545427Z",
"url": "https://files.pythonhosted.org/packages/8f/8e/89d66d1fc20266281e9a8172d63a015d7fbb22088a8dd15100f8a1090a13/uiuapy-0.2.0-cp312-cp312-macosx_15_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "9e57792e22cfbc8ebae4c4fa10d3256c286ec716703f379a443f86289bd480dc",
"md5": "ed1e6ba8827496187193981b17bf2412",
"sha256": "24cea6d98d1957305e815a9ddeab77e287fb4af58a8d3ca3ffe55be90495cf91"
},
"downloads": -1,
"filename": "uiuapy-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "ed1e6ba8827496187193981b17bf2412",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.9",
"size": 10533420,
"upload_time": "2025-08-24T23:05:05",
"upload_time_iso_8601": "2025-08-24T23:05:05.863589Z",
"url": "https://files.pythonhosted.org/packages/9e/57/792e22cfbc8ebae4c4fa10d3256c286ec716703f379a443f86289bd480dc/uiuapy-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "da3946e55e1009f83230563abacc3c3e47d2d8581378763b9ad3866b25c76291",
"md5": "23744a6167528d6cdadd18a2933ed254",
"sha256": "c80cdfee7736315f9f1ece23088fdec24b92520c417e98077492c22c71bf20bb"
},
"downloads": -1,
"filename": "uiuapy-0.2.0-cp312-cp312-win_amd64.whl",
"has_sig": false,
"md5_digest": "23744a6167528d6cdadd18a2933ed254",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.9",
"size": 9497985,
"upload_time": "2025-08-24T23:05:08",
"upload_time_iso_8601": "2025-08-24T23:05:08.037848Z",
"url": "https://files.pythonhosted.org/packages/da/39/46e55e1009f83230563abacc3c3e47d2d8581378763b9ad3866b25c76291/uiuapy-0.2.0-cp312-cp312-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "b3a5d6870ff431c32ebfb211165d1f6dfca918bc271785885b91452f44541ab0",
"md5": "07d8dfc21984634e94c2fb19a2b79c8d",
"sha256": "97766f4c087a3bdad07280d7778c9604800eac9a80aaed8973ce03a09b6f0dc7"
},
"downloads": -1,
"filename": "uiuapy-0.2.0-cp313-cp313-macosx_15_0_arm64.whl",
"has_sig": false,
"md5_digest": "07d8dfc21984634e94c2fb19a2b79c8d",
"packagetype": "bdist_wheel",
"python_version": "cp313",
"requires_python": ">=3.9",
"size": 9054457,
"upload_time": "2025-08-24T23:05:10",
"upload_time_iso_8601": "2025-08-24T23:05:10.155750Z",
"url": "https://files.pythonhosted.org/packages/b3/a5/d6870ff431c32ebfb211165d1f6dfca918bc271785885b91452f44541ab0/uiuapy-0.2.0-cp313-cp313-macosx_15_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "2bda07e5d9cbc6b8c612f207f14c1f295387d4cddaf44abe6b56a3f5ba677163",
"md5": "7fccf727b63c110dcf0fca229ba8e6bd",
"sha256": "8ed6f1b0af7d545e44a0c4a8edf0c945c604d55a78a5c42c421622f44a7a0716"
},
"downloads": -1,
"filename": "uiuapy-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "7fccf727b63c110dcf0fca229ba8e6bd",
"packagetype": "bdist_wheel",
"python_version": "cp313",
"requires_python": ">=3.9",
"size": 10533114,
"upload_time": "2025-08-24T23:05:12",
"upload_time_iso_8601": "2025-08-24T23:05:12.318148Z",
"url": "https://files.pythonhosted.org/packages/2b/da/07e5d9cbc6b8c612f207f14c1f295387d4cddaf44abe6b56a3f5ba677163/uiuapy-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7c24e9cd7e6a8a184f3af421c74b25f04b226828f48ff911f89aa873f225ef3e",
"md5": "10d7de24c67e3cbe1b362d7b0bdc73a3",
"sha256": "6ac840afbd8ddf45acb43c6b59d06ee4feeed1b1d1b455d1c89cae48e75cc314"
},
"downloads": -1,
"filename": "uiuapy-0.2.0-cp313-cp313-win_amd64.whl",
"has_sig": false,
"md5_digest": "10d7de24c67e3cbe1b362d7b0bdc73a3",
"packagetype": "bdist_wheel",
"python_version": "cp313",
"requires_python": ">=3.9",
"size": 9497224,
"upload_time": "2025-08-24T23:05:14",
"upload_time_iso_8601": "2025-08-24T23:05:14.513884Z",
"url": "https://files.pythonhosted.org/packages/7c/24/e9cd7e6a8a184f3af421c74b25f04b226828f48ff911f89aa873f225ef3e/uiuapy-0.2.0-cp313-cp313-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "f7b01ff0db56b03bd504a5c4870629144170b07196650c1e50cdabf6c63fda32",
"md5": "f1bbbae22b8e1106e2853d70f5489e43",
"sha256": "cf1578d95a5c87b672b3913438658ef88d229decd9cfee4c14cc598c4c96e997"
},
"downloads": -1,
"filename": "uiuapy-0.2.0-cp39-cp39-macosx_11_0_universal2.whl",
"has_sig": false,
"md5_digest": "f1bbbae22b8e1106e2853d70f5489e43",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9",
"size": 9057783,
"upload_time": "2025-08-24T23:05:16",
"upload_time_iso_8601": "2025-08-24T23:05:16.671541Z",
"url": "https://files.pythonhosted.org/packages/f7/b0/1ff0db56b03bd504a5c4870629144170b07196650c1e50cdabf6c63fda32/uiuapy-0.2.0-cp39-cp39-macosx_11_0_universal2.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "69a903e6812e50a9513a55db59d536e87ad84f477df7a92a36798169dd511d62",
"md5": "31f07709d33cc394fd30535ccd73ec12",
"sha256": "08059b56bd87a833ed8a233ea82dd3df62baadc21c79730e09912190eb4fc4e3"
},
"downloads": -1,
"filename": "uiuapy-0.2.0-cp39-cp39-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "31f07709d33cc394fd30535ccd73ec12",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9",
"size": 10534542,
"upload_time": "2025-08-24T23:05:18",
"upload_time_iso_8601": "2025-08-24T23:05:18.441199Z",
"url": "https://files.pythonhosted.org/packages/69/a9/03e6812e50a9513a55db59d536e87ad84f477df7a92a36798169dd511d62/uiuapy-0.2.0-cp39-cp39-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8f81832dc8bf66818c0e5df9347558e6cd5875b02876cafedb7ab8a54adf3437",
"md5": "3f086eb8547c1b6a6d0385cfccae678d",
"sha256": "e58b149660c639fb4a2e38ae9d16458f56e9a69a02cbe03480abc4cf7c278c24"
},
"downloads": -1,
"filename": "uiuapy-0.2.0-cp39-cp39-win_amd64.whl",
"has_sig": false,
"md5_digest": "3f086eb8547c1b6a6d0385cfccae678d",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9",
"size": 9497007,
"upload_time": "2025-08-24T23:05:20",
"upload_time_iso_8601": "2025-08-24T23:05:20.344652Z",
"url": "https://files.pythonhosted.org/packages/8f/81/832dc8bf66818c0e5df9347558e6cd5875b02876cafedb7ab8a54adf3437/uiuapy-0.2.0-cp39-cp39-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "e2054c522004df83b988555928d976f8945d223a39704b51f98abf4a46558562",
"md5": "268951314d0987a7a8aadfa92ad0d017",
"sha256": "bc1f8b4397b00dfdca529bce4339c7e2a8bdf9bc7c7a0edd6a664b83b5de5c50"
},
"downloads": -1,
"filename": "uiuapy-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "268951314d0987a7a8aadfa92ad0d017",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 36877,
"upload_time": "2025-08-24T23:05:22",
"upload_time_iso_8601": "2025-08-24T23:05:22.256632Z",
"url": "https://files.pythonhosted.org/packages/e2/05/4c522004df83b988555928d976f8945d223a39704b51f98abf4a46558562/uiuapy-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-24 23:05:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bergkvist",
"github_project": "uiuapy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "uiuapy"
}