Skip to main content

ezvectors

A fast and lightweight 2D vector class for Python. No dependencies required.

I built this because I needed vectors for my initial prototype of a 2D physics engine and using NumPy for some really simple vector math is genuinely slower than pure Python. The overhead of calling into compiled C code through Python's FFI for something as small as adding two floats together completely negates any performance benefit. So I wrote my own vector library!

ezvectors gives you a Vector2 class that uses __slots__ for a small memory footprint, avoids unnecessary object allocation in arithmetic, and works seamlessly with plain tuples.

You can install ezvectors via pip:

pip install ezvectors

Usage

from ezvectors import Vector2

a = Vector2(3, 4)
b = Vector2(1, 2)

a + b             # Vector2(4, 6)
a - (1, 1)        # Vector2(2, 3) — tuples work everywhere
a * 2             # Vector2(6, 8)
a.magnitude()     # 5.0
a.normalize()     # Vector2(0.6, 0.8)
a.dot(b)          # 11
a.distance_to(b)  # 2.8284...
a.rotate_deg(90)  # Vector2(-4, 3)

Full API reference and examples in documentation.md.

Tests

pip install pytest
pytest tests/

License

MIT — see LICENSE.md.

Metadata

Release files for ezvectors 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ezvectors 0.1.2
File Size Uploaded Provenance Actions
ezvectors-0.1.2.tar.gz 5.3 kB Without provenance Details for ezvectors-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ezvectors 0.1.2
File Interpreter ABI Platform Actions
ezvectors-0.1.2-py3-none-any.whl Python 3 none any Details for ezvectors-0.1.2-py3-none-any.whl

Total release size: 9.7 kB

Release files / ezvectors-0.1.2.tar.gz

Download URL ezvectors-0.1.2.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
38f0705ac4f6a4057d564d0ac91ec9413ad907751eaffe3c5914cdbd5d342963
BLAKE2b-256 checksum
How to use checksums
01a150328e96a102109f82d190005f52320e03d4692b64d9d47b3bc8274244ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / ezvectors-0.1.2-py3-none-any.whl

Download URL ezvectors-0.1.2-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55dfbe0970b2a51b9db4e98e81fafcebfb41da5817351a58308ac3a3831e0a2b
BLAKE2b-256 checksum
How to use checksums
09dc73ab5338604fdd78b08e8d2fc84c7daf7c79e598d89ae791e9adcfe2905d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for ezvectors 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page