skillfed

fastnumbers

Super-fast and clean conversions to numbers.

fastnumbers v5.2.0 240.7K downloads/30d#8,900 on PyPI112
Permissive license MIT Active released

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 fastnumbers

uv

uv add fastnumbers

poetry

poetry add fastnumbers

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Financial and Insurance IndustryIntended Audience :: Information TechnologyIntended Audience :: Science/ResearchIntended Audience :: System AdministratorsNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: Scientific/Engineering :: Information AnalysisTopic :: Text ProcessingTopic :: Text Processing :: FiltersTopic :: Utilities

Tags

fast string to number conversionint float parsing performancenumeric type checkingerror handling number conversionbatch convert strings to numbersunicode numeral supporttype validation for numbers
performance-optimizationnumeric-parsingtype-validation

More Utilities packages