Skip to content

Make as a C module (with Cython) #10

@suminb

Description

@suminb

Our preliminary test shows promising results. Building base62 with Cython results in great improvement in performance.

Test code

import random

import base62


for _ in range(1000000):
    value = random.randint(0, 0xffffffff) 
    encoded = base62.encode(value)
    assert base62.decode(encoded) == value

Test with native Python (3.5)

(pybase62) ➜  base62 git:(develop) ✗ time python test.py
python test.py  8.41s user 0.00s system 99% cpu 8.420 total

Test with Cython

(pybase62) ➜  base62 git:(develop) ✗ time python test.py
python test.py  6.63s user 0.00s system 99% cpu 6.636 total

That's approximately 21% of speed improvement. More thorough tests shall be conducted in the near future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions