Registry / web-framework / fastcore

fastcore

JSON →
library2.2.16pypypi✓ verified 31d ago

fastcore is a Python library that 'supercharges' Python for fastai development, but is useful independently. It extends Python with features inspired by other languages like multiple dispatch from Julia, mixins from Ruby, and utilities for functional programming and parallel processing. It aims to eliminate boilerplate and add useful functionality for common tasks, with frequent patch releases.

pip install fastcore
INSTALL
IMPORT
SIG · FASTCORE
F
fastcore
web-frameworkpythonv2.2.16
Install
1.8s avg
Import
438ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v2.2.16 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.466s · 18.9MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.8s · import 0.410s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fastcore.all
✓ from fastcore.all import *
This is the recommended way to import fastcore for convenience, as the library is designed to allow safe `import *` by defining `__all__` in its modules.
typedispatch
✓ from plum import dispatch
✗ from fastcore.dispatch import typedispatch
The `typedispatch` system is being replaced by `plum-dispatch`. Users should migrate to `plum` for multiple dispatch functionality.

This quickstart demonstrates key `fastcore` utilities: the `L` collection for enhanced list operations, the `parallel` function for easy multiprocessing, and `store_attr` and `basic_repr` for reducing class boilerplate.

import time from fastcore.all import * # L: An enhanced list-like object with many utility methods l_data = L(range(10)).shuffle() print(f"Original L: {l_data}") print(f"Filtered (>=5): {l_data.filter(ge(5))}") # 'ge' is an operator function from fastcore.all # parallel: Easily run functions in parallel def slow_square(x): time.sleep(0.01) # Simulate some work return x*x results = parallel(slow_square, l_data, n_workers=2) print(f"Parallel squared results: {results}") # store_attr and basic_repr: Reduce boilerplate in classes class MyClass: def __init__(self, a, b=10): store_attr() # Automatically stores 'a' and 'b' as self.a, self.b __repr__ = basic_repr('a,b') # Generates a clean __repr__ obj = MyClass(5, b=20) print(f"MyClass instance: {obj}")
Debug
Known issues
breakingThe multiple dispatch system (`@typedispatch`, `TypeDispatch`) in `fastcore.dispatch` is being replaced by the `plum-dispatch` library. Code relying on fastcore's internal dispatch system will need to be updated.
fix
Install `plum-dispatch` (`pip install plum-dispatch`) and update imports from `fastcore.dispatch` to `plum` (e.g., `from plum import dispatch`). If using `TypeDispatch` classes, switch to `plum.Function`.
affects: Versions where Plum integration began (check fastcore.fast.ai documentation for specifics).
gotchaThe `fastcore.all.ifnone(a, b)` function eagerly evaluates both `a` and `b`. This differs from Python's standard `b if a is None else a` conditional expression, which short-circuits and only evaluates `b` if `a` is `None`. This can lead to unexpected side effects or performance issues if `b` is a complex or side-effecting operation.
fix
For potentially costly or side-effecting default values, use the standard Python conditional expression `b if a is None else a` directly, or ensure that `b` is pre-computed or a simple literal.
affects: All versions.
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'fastcore'
The `fastcore` library is not installed in your current Python environment.
fix
Install the library using pip: `pip install fastcore` or if you use Anaconda: `conda install fastcore -c fastai`.
AttributeError: module 'fastcore' has no attribute 'utils'
This usually indicates an outdated `fastcore` installation where submodules might not be correctly exposed, or an attempt to access internal modules that are not directly available as top-level attributes in older versions or specific environments. Modern `fastcore` typically uses `fastcore.all` for convenience.
fix
Update `fastcore` to the latest version: `pip install -U fastcore`. If you need specific utilities, consider using `from fastcore.all import *` to bring common utilities into your namespace, or `from fastcore import utils` if you intend to use `fastcore.utils` directly, assuming it's available in your version.
ImportError: Could not import '__path__' from fastcore.dispatch - this module has been moved to the fasttransform package.
This error occurs in `fastcore` versions 1.8.0 and above because the `dispatch` module (or parts of it) was moved to a new `fasttransform` package, introducing a breaking change for dependent libraries like `fastai` or `tsai` that might be using older import paths.
fix
You have two main options: 1) Downgrade `fastcore` to a version prior to 1.8.0, for example: `pip install fastcore<1.8.0` (or specifically `pip install fastcore==1.7.29` as suggested in some contexts). 2) Update the dependent library (e.g., `fastai` or `tsai`) to a version that is compatible with the newer `fastcore` and `fasttransform` structure, or refactor your code to use `fasttransform` if you were directly importing from `fastcore.dispatch`.
TypeError: 'module' object is not callable
When `from fastai.vision.all import *` (or similar `from fastcore.all import *`) is used, it can shadow Python's built-in `all()` function, replacing it with a module object. Consequently, attempts to call the built-in `all()` will result in this error.
fix
Avoid using `from fastai.vision.all import *` if you need to use the built-in `all()` function. Instead, import specific functions you need, or explicitly refer to the built-in `all()` using `import builtins` and then `builtins.all()`. Alternatively, if you wish to use the `fastcore` / `fastai` `all` function, ensure you are calling it with the correct arguments as defined by the library.
Upgrade
Version history
2.2.16latest on PyPI · released Aug 26, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
20
OpenAI (training)
1
Resources
fastcore — pip install fastcore · libregistry