The fastest 2D object rendering library for Python
Project description
FastObjects
The fastest 2D object rendering library for Python.
FastObjects renders thousands of 2D sprites and shapes per frame with a single OpenGL draw call per batch. State lives in flat NumPy arrays instead of per-object Python instances, so you mutate positions with array slicing and let the GPU do the rest.
Installation
pip install fastobjects
Quick start
import fastobjects as fo
win = fo.Window(800, 600, title="FastObjects demo")
sprites = fo.SpriteBatch("player.png", capacity=1000)
group = sprites.spawn(1, x=400, y=300)
@win.frame
def update(dt: float) -> None:
if win.keys[fo.KEY_RIGHT]:
group.pos[:, 0] += 200 * dt
win.clear(0.1, 0.1, 0.1)
win.draw(sprites)
if win.keys[fo.KEY_ESCAPE]:
win.request_close()
win.run()
Windowopens a native GLFW window with an OpenGL 3.3 core context and drives the frame loop (run()calls your@win.framecallback every frame withdt).win.keys[fo.KEY_X]andwin.mouseexpose polled input state.SpriteBatchholds up tocapacitytextured sprites;spawn()returns aSpriteGroupwhose.pos,.size,.rot, and.colorare NumPy views into the batch — writing to them updates the sprites directly, no per-object overhead.ShapeBatchworks the same way for rectangles, circles, and lines (batch.rects(...),batch.circles(...),batch.lines(...)), useful for debug overlays or non-textured geometry.win.draw(*batches)issues one draw call per batch, in the order given.
Why it's fast
FastObjects is written in Python, but the hot path isn't: sprite/shape state
lives in flat NumPy arrays, and each batch.draw() uploads the whole array
and issues a single OpenGL draw call (via moderngl) for the entire
batch — no per-object Python loop, no per-object GPU call. The interpreter
overhead that usually kills naive Python renderers never touches the
per-sprite path.
Benchmarks
Sprites sustained at 60 fps, measured on the same machine (AMD Radeon RX 580,
Python 3.13) against other Python rendering libraries — see
benchmarks/RESULTS.md for methodology and full
history:
| Framework | Sprites @ 60 fps |
|---|---|
| fastobjects | 218,809 |
| arcade | 5,692 |
| raylib | 5,692 |
| pyglet | 3,795 |
| pygame-ce | 1,687 |
Note: raylib and pygame-ce numbers above reflect a specific run in that
history file — check benchmarks/RESULTS.md for the full, dated series and
hardware details before quoting a number as "current".
Development
Install with development dependencies:
pip install -e ".[dev,bench]"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastobjects-0.2.0.tar.gz.
File metadata
- Download URL: fastobjects-0.2.0.tar.gz
- Upload date:
- Size: 78.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f85b01060d79729a1cc5d292702ae51393066be83cd986128239a712cfe464fd
|
|
| MD5 |
65a77b3b64fdf93a781d6571b81cca9c
|
|
| BLAKE2b-256 |
9d267f811c26118fb3130002b2087354818adbe78dfbe7e9373d7fae8365dd0d
|
Provenance
The following attestation bundles were made for fastobjects-0.2.0.tar.gz:
Publisher:
publish.yml on Enzo-Azevedo/FastObjects
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastobjects-0.2.0.tar.gz -
Subject digest:
f85b01060d79729a1cc5d292702ae51393066be83cd986128239a712cfe464fd - Sigstore transparency entry: 2104218104
- Sigstore integration time:
-
Permalink:
Enzo-Azevedo/FastObjects@d68814c5696370d63cde33c198f0ee882a527600 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Enzo-Azevedo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d68814c5696370d63cde33c198f0ee882a527600 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastobjects-0.2.0-py3-none-any.whl.
File metadata
- Download URL: fastobjects-0.2.0-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2aa103860a9a7a85997e4bc9b7c3495827c4541ce160c63a79620ca07b40b4f
|
|
| MD5 |
90f206554295eb4ee0cd6437da8ad733
|
|
| BLAKE2b-256 |
98f25501e822b93732621848b3f8aacaf9fb6f954f2a257326cdcea194fb02b5
|
Provenance
The following attestation bundles were made for fastobjects-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on Enzo-Azevedo/FastObjects
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastobjects-0.2.0-py3-none-any.whl -
Subject digest:
a2aa103860a9a7a85997e4bc9b7c3495827c4541ce160c63a79620ca07b40b4f - Sigstore transparency entry: 2104218347
- Sigstore integration time:
-
Permalink:
Enzo-Azevedo/FastObjects@d68814c5696370d63cde33c198f0ee882a527600 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Enzo-Azevedo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d68814c5696370d63cde33c198f0ee882a527600 -
Trigger Event:
push
-
Statement type: