Skip to main content

Python API

FOSU is in active development; its API may change without compatibility shims. Parsing returns eager, mutable dataclasses and lists, detached from native memory.

Install and use

Requires CPython 3.10+. Stable-ABI wheels target glibc and musl Linux on x86-64 and AArch64, plus macOS 11+ on Intel and Apple Silicon. One wheel per platform supports every compatible CPython version. Windows x86-64 is supported both natively and through the Linux x86-64 wheel under WSL.

python -m pip install fosu

Installing from a source checkout requires a C++20 compiler. An ordinary isolated pip install . provisions CMake and Ninja when needed; Unix Makefiles are also supported when Ninja is unavailable. --no-build-isolation makes the caller responsible for all build tools.

import fosu

beatmap = fosu.parse_file("map.osu")
for note in beatmap.hit_objects:
    if isinstance(note, fosu.Slider):
        print(note.time, note.length, note.control_points)

parse_file(path) accepts strings, bytes, and os.PathLike. parse(data) accepts buffer-protocol objects, including bytes, bytearray, memoryview, and arrays. Non-bytes buffers are copied to an immutable snapshot; encode text explicitly.

Inputs are bounded by available address space. Allocation failures raise MemoryError, and file failures raise OSError. Native parsing releases the GIL; Python value construction holds it. Concurrent calls return independent results. Malformed records are skipped and counted in beatmap.stats.malformed_lines; success does not certify playability.

Section selection

listing = fosu.parse_file(
    "map.osu",
    sections=fosu.Sections.METADATA | fosu.Sections.DIFFICULTY,
)

Both entry points accept keyword-only sections, defaulting to Sections.ALL. Members are GENERAL, EDITOR, METADATA, DIFFICULTY, EVENTS, TIMING_POINTS, COLOURS, and HIT_OBJECTS. Combine them with |. Skipped sections retain defaults and empty lists; Sections(0) selects none. Unsupported mask bits are rejected.

Include GENERAL for mode-dependent difficulty rules (such as mania CircleSize) and EVENTS for break-dependent combo rules. Only selected sections contribute malformed-line counts.

Results and important distinctions

The typed dataclasses in _model.py define the fields. Shared fields use C++ names. Important Python-specific behavior:

  • hit_objects contains Circle, Slider, Spinner, or HoldNote, in stable timestamp order. Narrow the union with isinstance.
  • Times are milliseconds. Slider endpoints are 0 by default. Pass calculate_slider_end_times=True to parse or parse_file to calculate them using curve distance, timing and repeats. Do not use slider endpoints unless calculation was requested. Accessing the field never computes or caches anything. Other object types still have numeric endpoints. Omitted sections use their default settings. Hit samples and slider edge fields remain text.
  • Slider control_points includes the head position, unlike the native point range. curve_segments preserves modern segment boundaries and explicit B-spline degrees. slides=2 means forward and back.
  • tag_list and bookmark_list are parsed conveniences alongside the tags and bookmarks text fields.
  • IDs and preview time map the -1 sentinel to None.
  • Strings decode with UTF-8 surrogateescape, preserving undecodable bytes.
  • Inherited timing-point NaN beat lengths are preserved; consumers must not treat them as ordinary slider velocities.

Values can be edited, copied with deepcopy, exported with dataclasses.asdict, or pickled. They do not validate assignments or recompute related fields: changing a slider's position does not move its stored head point, and changing type does not recalculate combo flags. dataclasses.replace is a shallow copy. Mutation does not change the input or another parse result.

Pass calculate_slider_paths=True to retain each slider's path (otherwise None). fosu.slider_position_at(slider.path, progress) is a pure query over that polyline, with progress clamped to [0, 1]. Returned PathPoint coordinates are relative to the head; add the slider's x/y for playfield coordinates. Paths alone do not calculate end times. Requesting both reuses their distance. Native code exposes the same query and Beatmap.slider_paths, indexed by slider.

calculate_slider_events=True additionally populates slider.events with HEAD, TICK, REPEAT, LEGACY_LAST_TICK, and TAIL records in official generator order, grouped by slider-span traversal. This is not necessarily timestamp order: a legacy last tick may be timed before a late tick or the repeat beginning its final span. The legacy event is the effective historical tail judgement, not an additional score or combo event; the real TAIL and slider end_time remain unchanged. This option includes path and end-time calculation. Each record has time, span index/start time, path progress, and a position relative to the head. Native code exposes Beatmap.slider_events, indexed by slider. Without the option, events are empty. These are path events using the decoded slider's timing, not a converted ruleset's nested hitobjects: no samples or catch conversion. Expansion beyond 1,048,576 events per map raises MemoryError rather than silently dropping events.

apply_stacking=True applies unmodded osu!standard stacking after parsing, including the pre-v6 algorithm. Hit-object x/y and absolute slider control points are adjusted before returning. obj.raw_position() subtracts the stacking offset from the current x/y, or returns x/y when stacking is absent. It can have small floating-point rounding differences. Coordinates are floats in both interfaces, including when stacking is disabled. Each object also retains stack_height and stack_offset in its Stacking value for inspection; do not add the offset again. Relative path/event positions remain unchanged: add them to the adjusted head. It includes path and end-time calculation, but not events. Native results use Beatmap.stacking, indexed by hit object. Other modes are unchanged; Python stacking is None when not calculated. Include GENERAL, DIFFICULTY, TIMING_POINTS and HIT_OBJECTS when selecting sections for meaningful results.

mods= accepts combined Mods values. EZ and HR adjust difficulty settings for osu!standard and osu!taiko; HR also reflects standard hit objects and slider control points vertically. EZ/HR require GENERAL and DIFFICULTY in sections. They are not yet supported for osu!catch or osu!mania because those modes require converted fruit offsets or resolved hit windows; support is planned. DT, NIGHTCORE, and HT support every mode and divide gameplay timeline values by 1.5, 1.5, and 0.75 respectively. This includes hit objects, calculated slider events, timing-point offsets and uninherited beat lengths, and breaks. General and Editor timestamp metadata remains in source-map time.

See compatibility for supported behavior and limitations; there is no ruleset conversion.

CPU selection

fosu.backend reports "avx2", "neon", or "scalar". Set FOSU_BACKEND=auto|scalar|avx2|neon before importing to select an engine. Unsupported explicit requests raise ImportError; selection stays fixed for the loaded extension. See development checks.

Release files for fosu 0.2.1

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

Source distribution (sdist)

Source distribution for fosu 0.2.1
File Size Uploaded
fosu-0.2.1.tar.gz 235.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for fosu 0.2.1
File
fosu-0.2.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
fosu-0.2.1-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
fosu-0.2.1-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
fosu-0.2.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
fosu-0.2.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details
fosu-0.2.1-cp310-abi3-macosx_11_0_x86_64.whl CPython 3.10 abi3 macOS 11.0+ x86-64 Details
fosu-0.2.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details

Total release size: 1.9 MB

Release files / fosu-0.2.1.tar.gz

Download URL fosu-0.2.1.tar.gz
Size 235.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f7cea34a6c12262a770f788b72873a8e6a9e8e2264d361da387bed9b531d4f02
BLAKE2b-256 checksum
How to use checksums
ffe94e792b906a7304513540ca8a12213304b5e364f22fa75a1371e878f64002
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / fosu-0.2.1-cp310-abi3-win_amd64.whl

Download URL fosu-0.2.1-cp310-abi3-win_amd64.whl
Size 325.4 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
940d999fa789f8c140d01fc74e372b117dc20963f93172cc2b5621937b632364
BLAKE2b-256 checksum
How to use checksums
4dc46e5c8a76c1000cc20ef7316c75929777ec1c2d515f488ef84114f136fa9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / fosu-0.2.1-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL fosu-0.2.1-cp310-abi3-musllinux_1_2_x86_64.whl
Size 269.4 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
99e4e357bf9ca5a60eebd0d2c1ac12ab6dde03f57fdd087def5602bffd55b372
BLAKE2b-256 checksum
How to use checksums
9642318723e465393a63bc5b1b9264c0e20541eb0edf358e045f10f4fd9991eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / fosu-0.2.1-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL fosu-0.2.1-cp310-abi3-musllinux_1_2_aarch64.whl
Size 260.5 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
dde361bb536e67e9b621b539e4daf99860815bcb5d3fa193c573ef10fe66f876
BLAKE2b-256 checksum
How to use checksums
a364ae429b6732060af863121cab41ebb5d79b1094c2b638c20ff31acf9b173e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / fosu-0.2.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL fosu-0.2.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 270.4 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
9c4d35967c1050dc24fa3e25c035049185c5e017d3238d2b35e5a176a7e1a0ae
BLAKE2b-256 checksum
How to use checksums
4a06d2adadad73a0ff93ba44d9c7a491c7840449b45f03d0bd41ac2df49d0cc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / fosu-0.2.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL fosu-0.2.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 261.3 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
72271be6c7b845888e547de6bf3d5fd1f6aafcede8a1429d61d2a7e70c353749
BLAKE2b-256 checksum
How to use checksums
021e6e0043eac8c23176c3a8e328ae40b1bec75dcd4727327beb742c8c9d49eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / fosu-0.2.1-cp310-abi3-macosx_11_0_x86_64.whl

Download URL fosu-0.2.1-cp310-abi3-macosx_11_0_x86_64.whl
Size 134.1 kB
Tags CPython 3.10 abi3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
b1393ea78ec271c43bd10484b677603710571a4a0e8fb0629c4fd787a3e4b796
BLAKE2b-256 checksum
How to use checksums
7747691bc0d9044cfbadbd5c5120a69b1d6435cf2f7a9b8449f970b10ef4f0f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / fosu-0.2.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL fosu-0.2.1-cp310-abi3-macosx_11_0_arm64.whl
Size 127.3 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f27430e104e7626f5f54e6c9a8f03aca39bdfa728ea0ed582164357986fa5b5b
BLAKE2b-256 checksum
How to use checksums
4c49f44788732d9f7284d6e66bb56125cbe0a10188488e7451fc5ebd1d96b8c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.2

8 release files

0.5.1

8 release files

0.5.0

8 release files

0.4.1

8 release files

0.4.0

8 release files

0.3.0

8 release files

This release

0.2.1 This release

8 release files

0.2.0

8 release files

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