Skip to content

Instantly share code, notes, and snippets.

View m-ad's full-sized avatar

Michael A. m-ad

View GitHub Profile
@m-ad
m-ad / float_perf.py
Created December 1, 2025 09:28
Compare performance of `is_float` check with try/except and regex
# /// script
# dependencies = ["numpy"]
# ///
"""
Goal:
Compare performance of two strategies to check if a string
can be converted to a float:
1) using try/except around float()
2) using a regular expression to match float shape