Skip to main content
https://travis-ci.org/Francesco149/pyttanko.svg?branch=master

osu! pp and difficulty calculator. pure python implementation of https://github.com/Francesco149/oppai-ng

this is meant to be a standalone single-file module that’s as portable as possible using only python 2.6+ builtins with no extra dependencies

if you need a command line interface, check out oppai-ng

usage

pyttanko is a single-file module, so the simplest way to use it is to simply drop it in your project’s folder:

cd my/project
curl https://raw.githubusercontent.com/Francesco149/pyttanko/master/pyttanko.py > pyttanko.py

this way, anyone who clones your project won’t have to install pyttanko as it will be bundled

if you prefer, it’s also available on pip

pip install pyttanko

or you can also manually install like so:

curl -L https://github.com/Francesco149/pyttanko/archive/HEAD.tar.gz -o HEAD.tar.gz
cd pyttanko-*
python setup.py install --user

check out

pydoc pyttanko

or

python -c "help('pyttanko')"

for the full documentation

minimal example:

#!/usr/bin/env python

import sys
import pyttanko as osu

p = osu.parser()
bmap = p.map(sys.stdin)

stars = osu.diff_calc().calc(bmap)
print("%g stars" % stars.total)

pp, _, _, _, _ = osu.ppv2(stars.aim, stars.speed, bmap=bmap)
print("%g pp" % pp)

which you can run with:

cat /path/to/file.osu | ./example.py

performance

pyttanko runs the test suite over 10 times slower than the original C implementation and uses ~8 times more memory, so if you need to batch process thousands of scores, you should consider writing native bindings for the C version.

tests were performed on linux 4.9.38, python 2.7.10 on a i7-4790k

this is still a pretty respectable speed considering python is interpreted

$ cd ~/src/pyttanko/
$ time -v ./run_test
...
    Command being timed: "./run_test"
    User time (seconds): 101.68
    System time (seconds): 0.61
    Percent of CPU this job got: 99%
    Elapsed (wall clock) time (h:mm:ss or m:ss): 1m 42.34s
    Average shared text size (kbytes): 0
    Average unshared data size (kbytes): 0
    Average stack size (kbytes): 0
    Average total size (kbytes): 0
    Maximum resident set size (kbytes): 88688
    Average resident set size (kbytes): 0
    Major (requiring I/O) page faults: 0
    Minor (reclaiming a frame) page faults: 631637
    Voluntary context switches: 1
    Involuntary context switches: 4116
    Swaps: 0
    File system inputs: 0
    File system outputs: 56
    Socket messages sent: 0
    Socket messages received: 0
    Signals delivered: 0
    Page size (bytes): 4096
    Exit status: 0

$ cd ~/src/oppai-ng/test
$ ./build
$ time -v ./oppai_test
...
    Command being timed: "./oppai_test"
    User time (seconds): 9.09
    System time (seconds): 0.06
    Percent of CPU this job got: 99%
    Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 9.15s
    Average shared text size (kbytes): 0
    Average unshared data size (kbytes): 0
    Average stack size (kbytes): 0
    Average total size (kbytes): 0
    Maximum resident set size (kbytes): 11840
    Average resident set size (kbytes): 0
    Major (requiring I/O) page faults: 0
    Minor (reclaiming a frame) page faults: 304
    Voluntary context switches: 1
    Involuntary context switches: 39
    Swaps: 0
    File system inputs: 0
    File system outputs: 0
    Socket messages sent: 0
    Socket messages received: 0
    Signals delivered: 0
    Page size (bytes): 4096
    Exit status: 0

Metadata

Release files for pyttanko 1.0.10

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

Source distribution (sdist)

Source distribution for pyttanko 1.0.10
File Size Uploaded
pyttanko-1.0.10.tar.gz 12.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyttanko 1.0.10
File Interpreter ABI Platform
pyttanko-1.0.10-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 26.9 kB

Release files / pyttanko-1.0.10.tar.gz

Download URL pyttanko-1.0.10.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
27a2040ae3d7c1fadab3998139d6fc414b45ed91af3f4a5fa58972ab6704f699
BLAKE2b-256 checksum
How to use checksums
8ed68a67f5d3170a88c1bb46aff3ab62648876be3f50d15753321b4e765e40dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyttanko-1.0.10-py2.py3-none-any.whl

Download URL pyttanko-1.0.10-py2.py3-none-any.whl
Size 14.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
4ad509356beacb4a78e246cb0806957d50c975ef98c9c055127fb928a9e2630a
BLAKE2b-256 checksum
How to use checksums
ecebe8f0480e42c19b5adb4fcbff1ef90f9fef42aa9454411a29397a05b1e01f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

2.1.0

2 release files

2.0.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.22

1 release file

1.0.20

1 release file

1.0.19

1 release file

1.0.18

1 release file

1.0.15

1 release file

1.0.14

1 release file

This release

1.0.10 This release

2 release files

1.0.9

2 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