better-optimize
A drop-in replacement for scipy optimize functions with quality of life improvements
What it is and what it does
better_optimize is a convenience layer over scipy's optimization routines that reduces boilerplate and adds visibility into long-running solves. It replaces scipy's nested `options` dictionaries with flat keyword arguments, normalizes callback signatures across different optimizers (minimize, root, basinhopping, differential_evolution), and provides optional rich progress bars showing iteration counts, elapsed time, objective values, and gradient/Hessian norms. It also handles fused objective functions that return multiple values (loss, gradient, Hessian) together, caching intermediate results to avoid redundant computation.
The package includes multi_optimize for parallel optimization from multiple starting points using different initialization strategies (uniform, normal, Sobol, Latin hypercube) and backends (sequential, loky, threading). It depends on numpy, scipy, rich, joblib, pandas, and threadpoolctl. Early stopping is supported by raising StopOptimization from a callback, and all results are standard scipy OptimizeResult objects, so downstream code needs no changes.
Use it for:
- Minimize a function with a live progress bar to monitor convergence without blocking output.
- Run the same callback logic across minimize, root, and basinhopping without rewriting for each method's signature.
- Optimize a triple-fused objective that computes value, gradient, and Hessian together, avoiding redundant computation.
- Search for the global minimum by launching many local optimizations in parallel from random starting points.
- Stop an optimization early when a target loss is reached, returning the best result so far.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A wrapper around scipy's optimize.minimize and optimize.root that adds progress bars, early stopping, flattened keyword arguments, and a unified callback API across different optimization methods.
Yes, if you regularly use scipy's optimize functions and want cleaner syntax, progress visibility, and unified callbacks. The low install friction, active maintenance, permissive license, and zero known vulnerabilities make it a safe addition. Best suited for interactive work and research; production code that calls scipy directly may not need the wrapper overhead.
Install
better-optimize on PyPI
pip
pip install better-optimizeuv
uv add better-optimizepoetry
poetry add better-optimizeInstalling better-optimize
Before you install
Low friction: pure Python wheel with standard scientific dependencies (numpy, scipy, rich, joblib, pandas, threadpoolctl). Active maintenance with recent releases.
License in practice
MIT License permits commercial and private use with minimal restrictions; attribution required but no copyleft obligations.
Quickstart
pip install better_optimize
import numpy as np
from better_optimize import minimize
def rosenbrock(x):
return sum(100.0*(x[1:] - x[:-1]**2.0)**2.0 + (1 - x[:-1])**2.0)
result = minimize(
rosenbrock,
x0=np.array([-1.0, 2.0]),
method="L-BFGS-B",
tol=1e-6,
maxiter=1000,
progressbar=True,
)
Requires Python 3.12 or later.
Verify before relying
- Whether progress bar display works correctly in all headless/non-terminal environments as claimed.
- Performance overhead of the wrapper layer relative to direct scipy calls for large-scale problems.
- Compatibility of fused function detection with all scipy optimizer variants.
Package facts
| License | MIT License (permissive) |
| Python support | supports the current Python release (>=3.12) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — numpy, scipy, rich, threadpoolctl, joblib, pandas |
| Maintenance | actively maintained — 83 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 206,389/month — #9,574 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: better_optimize-0.4.2-py3-none-any.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
scikit-optimizeScikit-Optimize is a library for optimizing…
permissive · top 15,000 on PyPI
optlangOptlang formulates and solves linear,…
permissive · top 15,000 on PyPI
autogradAutograd automatically computes derivatives of…
permissive · top 5,000 on PyPI
directsearchSolves unconstrained and linearly constrained…
copyleft · top 15,000 on PyPI
progressProvides terminal progress bars and spinners…
permissive · top 5,000 on PyPI
roptropt is a Python module for running robust…
copyleft · top 15,000 on PyPI
optaxOptax provides composable building blocks for…
permissive · top 5,000 on PyPI
amplpyamplpy is a Python interface to AMPL, an…
permissive · top 15,000 on PyPI