Caching
Extraction results are cached per type on the MetadataExtractor instance.
extractor = MetadataExtractor()
metadata1 = extractor.extract(Person)
metadata2 = extractor.extract(Person)
assert metadata1 is metadata2 # same dict object
# Force re-extraction (e.g. after runtime type modification)
metadata3 = extractor.extract(Person, refresh_cache=True)
- Caching is per-instance: two separate
MetadataExtractorobjects have independent caches. - Filtering and sorting applied at call time (via
filter_expr/sort_spec) are never stored in the cache. - Lifecycle hooks execute only during actual extraction, not on cache hits — use
refresh_cache=Trueto re-run them.