{"id":5220,"library":"fasttransform","title":"FastTransform","description":"Fasttransform is a Python library designed for creating reusable, reversible, and extensible data transformations. It is a core building block for data pipelines, particularly within the fastai ecosystem, and leverages multiple dispatch for type-based specialization of transforms. The current version is 0.0.2, and it appears to have a low release cadence with infrequent updates.","status":"active","version":"0.0.2","language":"en","source_language":"en","source_url":"https://github.com/AnswerDotAI/fasttransform","tags":["data transformation","fastai","pipeline","multiple dispatch","reversible transforms"],"install":[{"cmd":"pip install fasttransform","lang":"bash","label":"From PyPI"},{"cmd":"pip install git+https://github.com/AnswerDotAI/fasttransform.git","lang":"bash","label":"From GitHub (latest develop branch)"}],"dependencies":[{"reason":"Provides the multiple dispatch functionality used internally for type-based specialization.","package":"plum-dispatch","optional":false}],"imports":[{"symbol":"Transform","correct":"from fasttransform import Transform"},{"note":"The Pipeline class was moved from fastcore to fasttransform. Direct import from fastcore may lead to ModuleNotFoundError, especially with newer fastai versions.","wrong":"from fastcore.transforms import Pipeline","symbol":"Pipeline","correct":"from fasttransform import Pipeline"}],"quickstart":{"code":"from fasttransform import Transform, Pipeline\n\n# Create a simple transform using a decorator\n@Transform\ndef add_one(x: int) -> int:\n    return x + 1\n\n# Create a reversible transform\ndef multiply_by_two_encodes(x: int) -> int:\n    return x * 2\n\ndef multiply_by_two_decodes(x: int) -> int:\n    return x // 2\n\nMultiplyByTwo = Transform(multiply_by_two_encodes, multiply_by_two_decodes)\n\n# Use a Pipeline to chain transforms\nmy_pipeline = Pipeline([add_one, MultiplyByTwo])\n\n# Demonstrate usage\nresult_encoded = my_pipeline(5)\nprint(f\"Encoded result: {result_encoded}\") # Expected: (5 + 1) * 2 = 12\n\nresult_decoded = MultiplyByTwo.decode(result_encoded)\nprint(f\"Decoded result (MultiplyByTwo): {result_decoded}\") # Expected: 12 // 2 = 6","lang":"python","description":"This quickstart demonstrates how to define a simple transform using the `@Transform` decorator, create a reversible transform by passing encode and decode functions, and compose multiple transforms into a `Pipeline`."},"warnings":[{"fix":"Review type dispatch definitions to ensure unique matches for argument types, or explicitly specify the desired function.","message":"Migration from `fastcore.dispatch`'s `typedispatch` to `plum-dispatch` may introduce `AmbiguousLookupError` where `fastcore` would silently pick a function. `plum` is stricter to prevent unexpected behavior.","severity":"breaking","affected_versions":"All versions (due to underlying dependency change)"},{"fix":"Ensure `fasttransform` is installed and `Pipeline` is imported directly from `fasttransform`. If using `fastai` with older saved models, consider retraining or upgrading `fastai` and `fasttransform` to compatible versions. Downgrading `fastai` to v2.7.x was a workaround for some users, but generally updating is recommended.","message":"The `Pipeline` class has moved from `fastcore` to `fasttransform`. Older `fastai` versions (specifically 2.7.x) might expect `Pipeline` in `fastcore`, leading to `ModuleNotFoundError` when loading models or using certain functionalities.","severity":"breaking","affected_versions":"Potentially `fastai` versions 2.8.0 and higher when interacting with older saved models or explicit imports."},{"fix":"Always implement or provide the inverse function(s) (`decodes`) for any transform intended to be reversible.","message":"When implementing custom reversible transforms, remember to define both `encodes` and `decodes` methods for the `Transform` class or pass both functions to the `Transform` constructor. Forgetting the `decodes` method will prevent reversibility.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Carefully annotate types in `encodes`/`decodes` methods or decorator arguments. Provide a default implementation without type hints if a fallback behavior is desired for unhandled types.","message":"Fasttransform's type-based multiple dispatch, powered by `plum-dispatch`, will return the original input if no matching type annotation is found for an argument. This can lead to unexpected no-op behavior if types are not correctly annotated or handled.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Double-check the package name during installation (`pip install fasttransform`) and imports (`from fasttransform import ...`).","message":"There is another unrelated library named `fastflowtransform` on PyPI. Ensure you are installing and importing the correct library (`fasttransform`) for data pipeline transformations described here to avoid confusion.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}