Skip to main content

frepr

https://travis-ci.org/wemoloh/frepr.svg?branch=master

Fast float repr() for CPython using https://github.com/google/double-conversion. Approximately 8X faster than the built-in function.

Quick Start

>>> import frepr
>>> frepr.frepr(-1.8397892359791307e+134)
'-1.8397892359791307e+134'
>>> from timeit import timeit
>>> timeit('repr(-1.8397892359791307e+134)')
2.7296602272476758
>>> frepr.install()
>>> timeit('repr(-1.8397892359791307e+134)')
0.35723431229251545
>>> frepr.uninstall()

API

frepr.frepr(value)

Returns shortest string representation of a floating point value. The argument doesn’t have to be a float, as long as it is coercible to one (i.e. it has a __float__() method).

frepr.install()

Monkey-patches the Python runtime. Subsequent calls to repr() on floats will use the faster algorithm. This is safe to call multiple times.

frepr.uninstall()

Reverses the monkey-patching done by install(). Subsequent calls to repr() will use the original built-in algorithm. This is safe to call multiple times, even if install() was not called first.

Features

  • On average, approximately 8X faster than the standard function. (This result obtained on Python 3.6.0 64-bit/Windows 7/Intel Core i3 @ 2.93GHz. Test your own system with tests/perf.py).

  • Speeds up the standard json package (and any other library that relies on repr()).

  • Output is guaranteed to contain the shortest string of decimal digits necessary to uniquely identify the original IEEE 754 floating-point value.

  • Guaranteed to satisfy value == ast.literal_eval(frepr(value)).

  • Tested on CPython 2.6 through 3.6; probably works on other versions too.

Limitations

  • Currently, there is no support for alternative Python implementations (e.g. PyPy).

  • Output can be slightly different from the native function, due to floating-point rounding (but see accuracy guarantees above).

  • Has no effect on other built-in methods of converting floats to strings (e.g. str(), str.format(), "%f", "%g").

See Also

Metadata

Release files for frepr 0.1.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 frepr 0.1.1
File Size Uploaded
frepr-0.1.1.tar.gz 58.2 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for frepr 0.1.1
File
frepr-0.1.1-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
frepr-0.1.1-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
frepr-0.1.1-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
frepr-0.1.1-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
frepr-0.1.1-cp34-cp34m-win_amd64.whl CPython 3.4 CPython 3.4 pymalloc Windows x86-64 Details
frepr-0.1.1-cp34-cp34m-win32.whl CPython 3.4 CPython 3.4 pymalloc Windows x86-32 Details
frepr-0.1.1-cp27-cp27m-win_amd64.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-64 Details
frepr-0.1.1-cp27-cp27m-win32.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-32 Details

Total release size: 266.0 kB

Release files / frepr-0.1.1.tar.gz

Download URL frepr-0.1.1.tar.gz
Size 58.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c87f9a996b7767a887a4b1590b1ab6cbe33825e3793b505cc07f172152b294b4
BLAKE2b-256 checksum
How to use checksums
716bd9f3514a2a10b628b485f4b3a99119e70a7c99c748f03e9443e87e3cb39d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / frepr-0.1.1-cp36-cp36m-win_amd64.whl

Download URL frepr-0.1.1-cp36-cp36m-win_amd64.whl
Size 25.1 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
c7735e6a22fff426aaa28c274986de0eddfc7e3599aca42af9fd6095f50ad77d
BLAKE2b-256 checksum
How to use checksums
c3d3e3b048ae321334ab83046f198e7ec7bcea04c3652562d2929a4310e2bd95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / frepr-0.1.1-cp36-cp36m-win32.whl

Download URL frepr-0.1.1-cp36-cp36m-win32.whl
Size 20.8 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
466b4284b1e952c3e81c17208f709f2fbc1723b9a5deb9a9acbfeb90f4e86c35
BLAKE2b-256 checksum
How to use checksums
43faef937630bdb23aa295d4fc688bf15fccc51a47b19b29b54dbe0bdeb35e44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / frepr-0.1.1-cp35-cp35m-win_amd64.whl

Download URL frepr-0.1.1-cp35-cp35m-win_amd64.whl
Size 25.1 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
69a027a4605a8a5a4123cc91ad6f4d858d797116d20f604553df641cf53a469f
BLAKE2b-256 checksum
How to use checksums
6e3aabd2a0e15a986e307d0d9b65ec167249792e47e5bf9f90522d33d63e7f30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / frepr-0.1.1-cp35-cp35m-win32.whl

Download URL frepr-0.1.1-cp35-cp35m-win32.whl
Size 20.8 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
c84a066df6bee5df4f920c3d7817cb1bf94fdf262b6b828325fc7f61fd9c3872
BLAKE2b-256 checksum
How to use checksums
3f4f58a281854b6adde87829610947e49190271e8617d3d2120847636a7f1804
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / frepr-0.1.1-cp34-cp34m-win_amd64.whl

Download URL frepr-0.1.1-cp34-cp34m-win_amd64.whl
Size 31.5 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
a0bc461ceb128f072f59b2363a8f3df263664f40c7752029babdb2dd4dc1963f
BLAKE2b-256 checksum
How to use checksums
682799100364d1f99ccd9d04e6147ec9b19ebb58ba976fa49d8f3061549b6554
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / frepr-0.1.1-cp34-cp34m-win32.whl

Download URL frepr-0.1.1-cp34-cp34m-win32.whl
Size 26.7 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
e4174c4ad88416e76a9ea69ab1b3b3306488c40e1ab78f07a6213de8c5355ed1
BLAKE2b-256 checksum
How to use checksums
db04ee015654c91028e5d8ca064806438b3bd0afbf3805a58b87d9f8630e91c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / frepr-0.1.1-cp27-cp27m-win_amd64.whl

Download URL frepr-0.1.1-cp27-cp27m-win_amd64.whl
Size 31.1 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
b6c13f9eb8f5a739020832003e8e9547e38518a4df1f3c469cb73757e2487c8c
BLAKE2b-256 checksum
How to use checksums
97db1ca8018a6ca5f765c218e4ce98d0259ddf8f55adeb75fcd262f1956f2ae0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / frepr-0.1.1-cp27-cp27m-win32.whl

Download URL frepr-0.1.1-cp27-cp27m-win32.whl
Size 26.7 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
c20534b26f358ef18e1db7c9c2ab50729a7d0271509cc222bf101f234266c9f4
BLAKE2b-256 checksum
How to use checksums
9d989fe7b102d000448fa86761abaf5a816e308c6f9589ea786ff428dec7100d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.1 This release

9 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