Skip to main content

Python bindings for the Uiua programming language.

Project description

PyUiua

A Python binding for Uiua, allowing interaction between Uiua and Python.

Requirements

  • Python 3.10 or higher

Installation

pip install pyuiua

or see dev setup below for building from source

Example Usage

Basic Usage

import pyuiua

# Create a Uiua instance
uiua = pyuiua.Uiua()

# Basic evaluation - run code and pop result
uiua.run("/×⇡₁10") # Calculate 10 factorial
print(uiua.pop())  # 3628800

# Push Python values onto the stack
uiua.push(10)
uiua.push(20)
uiua.run("+") # Then run a Uiua operation
print(uiua.pop())  # 30

# Work with arrays
uiua.push([1, 2, 3, 4, 5])
uiua.run("/+")  # Sum the array
print(uiua.pop())  # 15

# Inspect the stack without modifying it
uiua.push(1)
uiua.push(2)
uiua.push(3)
print(uiua.stack())  # [1, 2, 3]
print(len(uiua))     # 3

# Clear the stack
uiua.clear()

API Reference

Uiua() - Create a Uiua instance

  • uiua.push(value) - Push a Python value onto the stack
  • uiua.pop() - Pop a value from the stack and return it as a python object
  • uiua.run(code) - Execute Uiua code on the current stack
  • uiua.stack() - Inspect the stack without modifying it
  • uiua.clear() - Remove all values from the stack
  • len(uiua) - Get the number of values on the stack

Type Conversions

The conversion of types is currently lossy. Both arrays and boxes convert to lists in Python, and Python lists convert to an array if they're homogeneous with a well-defined shape, otherwise a box. As a result, a box in Uiua of homogeneous values will become an array when converted to python and back.

  • Currently supports: most scalars, multidimensional arrays, and boxed arrays
  • Does not yet support: complex numbers, maps, functions, or user-defined types

Uiua → Python

Uiua Type Python Type
Scalar number int or float
Scalar char str
Scalar byte int
1D Array list
Multi-dimensional Array Nested list
Box Array (heterogeneous) list

Python → Uiua

Python Type Uiua Type
int Scalar number
float Scalar number
str Character array/string
list (homogeneous) Array
list (heterogeneous) Box Array

Development

Requirements

  • rustup (Rust installer)
  • uv (Python package manager)

Set-up

# Clone
git clone https://github.com/KatieLG/python-uiua.git
cd python-uiua

# Install dependencies
uv sync

# Build and install
uv run maturin develop

Dev Commands

Command Purpose
make dev Rebuild after making changes to Rust code
make test Run unit tests
make lint Run linters and type checkers
make format Auto-format code
make check Format, lint, and test
make build Build wheel for distribution
make test-release Publish to TestPyPI
make release Publish to PyPI

Links

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

pyuiua-0.0.5.tar.gz (49.3 kB view details)

Uploaded Source

Built Distributions

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

pyuiua-0.0.5-cp310-abi3-win_amd64.whl (10.0 MB view details)

Uploaded CPython 3.10+Windows x86-64

pyuiua-0.0.5-cp310-abi3-win32.whl (8.8 MB view details)

Uploaded CPython 3.10+Windows x86

pyuiua-0.0.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

pyuiua-0.0.5-cp310-abi3-macosx_11_0_arm64.whl (9.5 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

pyuiua-0.0.5-cp310-abi3-macosx_10_12_x86_64.whl (10.3 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file pyuiua-0.0.5.tar.gz.

File metadata

  • Download URL: pyuiua-0.0.5.tar.gz
  • Upload date:
  • Size: 49.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.10.2

File hashes

Hashes for pyuiua-0.0.5.tar.gz
Algorithm Hash digest
SHA256 c91457f3d90c592286a088539ffbe3e7efc403e348788438ee6cb5d6e80265aa
MD5 4e1b26b38fff05eb5490a1a052d890d3
BLAKE2b-256 61e29c5a55b68ee5670a3a7e84013789f141e3c846411be13548257fe7d60ebc

See more details on using hashes here.

File details

Details for the file pyuiua-0.0.5-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: pyuiua-0.0.5-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 10.0 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.10.2

File hashes

Hashes for pyuiua-0.0.5-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 79973869589804754fe4343ce144acd14ba3f3f9c9e4b0f1bbfad4770b1f6276
MD5 d3abfdd2d34f1ccceb60be9830835557
BLAKE2b-256 ddd233d4cca7331aba50fbec43942a36b935e6e10b05eabea1d1ac19741ae226

See more details on using hashes here.

File details

Details for the file pyuiua-0.0.5-cp310-abi3-win32.whl.

File metadata

  • Download URL: pyuiua-0.0.5-cp310-abi3-win32.whl
  • Upload date:
  • Size: 8.8 MB
  • Tags: CPython 3.10+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.10.2

File hashes

Hashes for pyuiua-0.0.5-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 653bde0ef60a8114f0a8423c8e6d43906ab3f14fbeb31e416a92819e043af01d
MD5 d57fb36e6daf12d05530e81fe93a6f06
BLAKE2b-256 bc1bf7cfd7e9a13dc89cd832521f449980ecb83597c62a980a9e462417d9e585

See more details on using hashes here.

File details

Details for the file pyuiua-0.0.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyuiua-0.0.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bdf62b545904ccbdee9be5be263ba01b14f0ccdf8af0868f7d136b80d46710b9
MD5 ad68544d2065971ba1e3add16b6dbf33
BLAKE2b-256 e8e659f529bf1b673c2853b88f845900997f42f0bdc930f5645f7fdc8bacf7b2

See more details on using hashes here.

File details

Details for the file pyuiua-0.0.5-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyuiua-0.0.5-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8fa5574ba7803b492abc35134636ff58f282cb49b3daf9d7a527c3628df40fdd
MD5 8c51aea5b7effbf0c53f4bbf702b80c6
BLAKE2b-256 71c9b224b67b239dd4f3c0f999101c4b3e8a7ad882cc885961752c49d0f35fa2

See more details on using hashes here.

File details

Details for the file pyuiua-0.0.5-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyuiua-0.0.5-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2cd4e070698a238f1c8d508b567a750e6b0e67abd76f7fdb617edae72c0612ee
MD5 029a100f4ee876ecbe91ce8059067d18
BLAKE2b-256 23ab17700f09e904516c94cd083060c455241e20fc5727f2b4e83d045efb3960

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