Skip to main content

osu! pp and difficulty calculator

Project description

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

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

pyttanko-1.2.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

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

pyttanko-1.2.0-py2.py3-none-any.whl (13.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pyttanko-1.2.0.tar.gz.

File metadata

  • Download URL: pyttanko-1.2.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.0 CPython/3.6.8

File hashes

Hashes for pyttanko-1.2.0.tar.gz
Algorithm Hash digest
SHA256 54a9455ba9ae19541ff4635348530ddf8710f80509dac8c10c91403dc3e98991
MD5 d6fbd57afe9e5d3d80bdccec7853b79b
BLAKE2b-256 bb8918ae47ec15189ae833efd1b7df121d91471309f9ca3570f78aa989c56dba

See more details on using hashes here.

File details

Details for the file pyttanko-1.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pyttanko-1.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.0 CPython/3.6.8

File hashes

Hashes for pyttanko-1.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 31ba1c2f441d53c9667c32c4335e7b0acb391dd2f22761185786119d2b19f39b
MD5 42916011447bc74e734a1b0b0655628c
BLAKE2b-256 08fb75df4f27459f603902d4930de5cd468983ecd5356501d4fc9f9e54986d26

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