fastnumbers
Super-fast and clean conversions to numbers.
What it is and what it does
fastnumbers is a Python module that wraps and accelerates conversions from strings and other types to int, float, or real numbers. It provides three categories of functions: error-handling functions (try_float, try_int, try_real, try_forceint) that return a fallback value or original input on failure, checking functions (check_float, check_int, etc.) to validate whether input could be converted, and drop-in replacements for Python's built-in int() and float() that aim for speed parity or better. The module handles edge cases like unicode numerals, inf/nan substitution, and batch operations on iterables via a map option.
The package is built as a compiled extension (wheels for Python 3.9–3.14 on common platforms) with no runtime dependencies, making it lightweight to install. It targets use cases where numeric parsing is a bottleneck—data processing pipelines, financial calculations, scientific computing, and bulk string-to-number conversions where the speed gains (claimed up to 5x for floats, 10x for error handling) justify the added dependency.
Use it for:
- Parsing CSV or JSON data with numeric fields where conversion speed or robust error handling is critical
- Validating user input or API payloads for numeric types before processing
- Batch converting lists of strings to floats or ints with a single call and 2x speedup over list comprehensions
- Handling unicode numerals (e.g., Roman numerals, circled digits) in text-to-number pipelines
- Replacing Python's built-in int/float in performance-sensitive numeric parsing loops
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts strings and other inputs to numbers (int, float, or real) with fast, flexible error handling and type-checking functions that outperform Python's built-in int() and float().
Yes, if numeric parsing is a measurable bottleneck in your application. The package is stable (Production/Stable status, active maintenance, no known vulnerabilities), has zero runtime dependencies, and offers genuine performance gains for string-to-number conversions and batch operations. Install with caution if you rely on undocumented corner-case behavior of Python's int/float, as the documentation warns of specific differences; otherwise, it is a safe, low-friction upgrade.
Install
fastnumbers on PyPI
pip
pip install fastnumbersuv
uv add fastnumberspoetry
poetry add fastnumbersInstalling fastnumbers
Before you install
Medium install friction due to compiled wheels for multiple platforms and Python versions (3.9–3.14). Active maintenance with recent release (48 days old) and steady repository activity (112 stars) suggests reliable ongoing support.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects with minimal obligations.
Quickstart
from fastnumbers import try_float, try_int
# Convert string to float, return original on failure
result = try_float('56.07')
# Convert with fallback value
result = try_float('bad input', on_fail=0)
# Batch convert with map option
items = try_float(['5', '4.5', '34567.6'], map=list)
Requires Python >= 3.9; compiled wheels available for common platforms but source build may require a C compiler on unsupported architectures.
Verify before relying
- Whether the claimed 2x–10x speedups hold for typical real-world workloads in your use case
- Exact behavior differences from built-in int/float in corner cases mentioned in documentation
- Performance of numpy array conversion (try_array) relative to alternatives in your data pipeline
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 48 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 240,745/month — #8,900 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: fastnumbers-5.2.0-cp310-cp310-macosx_10_9_x86_64.whl; fastnumbers-5.2.0-cp310-cp310-macosx_11_0_arm64.whl; fastnumbers-5.2.0-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; fastnumbers-5.2.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; fastnumbers-5.2.0-cp310-cp310-musllinux_1_2_aarch64.whl; fastnumbers-5.2.0-cp310-cp310-musllinux_1_2_x86_64.whl; fastnumbers-5.2.0-cp310-cp310-win32.whl; fastnumbers-5.2.0-cp310-cp310-win_amd64.whl; fastnumbers-5.2.0-cp310-cp310-win_arm64.whl; fastnumbers-5.2.0-cp311-cp311-macosx_10_9_x86_64.whl; fastnumbers-5.2.0-cp311-cp311-macosx_11_0_arm64.whl; fastnumbers-5.2.0-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; fastnumbers-5.2.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; fastnumbers-5.2.0-cp311-cp311-musllinux_1_2_aarch64.whl; fastnumbers-5.2.0-cp311-cp311-musllinux_1_2_x86_64.whl; fastnumbers-5.2.0-cp311-cp311-win32.whl; fastnumbers-5.2.0-cp311-cp311-win_amd64.whl; fastnumbers-5.2.0-cp311-cp311-win_arm64.whl; fastnumbers-5.2.0-cp312-cp312-macosx_10_13_x86_64.whl; fastnumbers-5.2.0-cp312-cp312-macosx_11_0_arm64.whl
Keywords: conversion, numeric, performance
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
typepyTypepy checks, validates, and converts Python…
permissive · top 5,000 on PyPI
infinityProvides an Infinity class that can be compared…
permissive · top 15,000 on PyPI
roman-numerals-pyConverts between integers and Roman numerals,…
permissive · top 5,000 on PyPI
dicttoxmlConverts Python dictionaries and other native…
copyleft · top 5,000 on PyPI
ml-dtypesml_dtypes provides NumPy-compatible data types…
permissive · top 1,000 on PyPI
romanConverts between Arabic integers and Roman…
unclear · top 5,000 on PyPI
django-phonenumber-fieldProvides a Django model field for storing,…
permissive · top 5,000 on PyPI
DataPropertyExtracts and classifies properties from…
permissive · top 5,000 on PyPI
bnunicodenormalizerNormalizes Bangla Unicode text by fixing…
permissive · top 15,000 on PyPI
cheap-reprProvides short, fast, configurable string…
permissive · top 15,000 on PyPI