--- id: marshmallow-fastoneofschema version: "2025.9.2.1.dev7" license: Copyright 2016-2017 Maxim Kulkin Copyright 2018 Alex Rothberg and contributors Copyright 2024 Steven Loria and contributors Copyright 2025 Kalepa Permission is hereby granted, free of charge, to any… (full text in the JSON record) license_treatment: permissive maintenance: aging --- # marshmallow-fastoneofschema — fast marshmallow multiplexing schema License: permissive · Maintenance: aging · Downloads: 194.6K/mo ## What it is and what it does marshmallow-fastoneofschema is a drop-in replacement for marshmallow-oneofschema that adds polymorphic schema support to marshmallow. It lets you define a single schema that can serialize and deserialize multiple object types by routing each object to the appropriate sub-schema based on its type. During serialization, it inspects the object type, selects the matching schema, and adds a discriminator field (by default named 'type') to the output. During deserialization, it reads the discriminator field to determine which schema to use for reconstruction. The package is designed as a performance-optimized fork with aggressive instance caching and reduced overhead for batch operations. It includes a .pth hook that redirects imports of the original marshmallow-oneofschema to this fork, allowing it to work as a transparent replacement. It also ships a DeepFriedMarshmallow plugin for JIT inlining of nested OneOfSchema fields. Configuration is available via environment variables (FOO_DISABLE_AGGRESSIVE_MODE, FOO_CONTEXT_ISOLATION) and per-schema class attributes. Use it for: - Serialize heterogeneous lists of objects (e.g., different event types) to JSON with automatic type tagging for deserialization. - Build REST API responses that contain polymorphic data structures without manual type-checking logic. - Deserialize incoming JSON payloads that include a type discriminator into the correct Python object instances. - Replace an existing marshmallow-oneofschema installation with a performance-optimized version without code changes. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Extends marshmallow to handle polymorphic schema (de)serialization by automatically routing objects to the correct schema based on type, adding a type discriminator field to the output. Yes, if you need polymorphic schema support in marshmallow and want a drop-in replacement for marshmallow-oneofschema. The low install friction, permissive license, and zero known vulnerabilities make it a straightforward choice. However, the aging maintenance status (no updates since initial release on 2025-09-02) and very low repository stars (1) suggest limited community adoption and testing; evaluate whether the performance claims and stability are suitable for your use case before committing to production. ## Install pip install marshmallow-fastoneofschema uv add marshmallow-fastoneofschema poetry add marshmallow-fastoneofschema ## Installing marshmallow-fastoneofschema Before you install: Low install friction with a single runtime dependency on marshmallow. Maintenance status is aging—the package was first released on 2025-09-02 with no updates since, though the repository remains active and unarchived. License in practice: MIT licensed with permissive terms. You can use, modify, and distribute the package freely with minimal restrictions, provided you retain the copyright notice and license text. Quickstart: pip install marshmallow-fastoneofschema from marshmallow_fastoneofschema import OneOfSchema import marshmallow class MyUberSchema(OneOfSchema): type_schemas = {"Foo": FooSchema, "Bar": BarSchema} MyUberSchema().dump([Foo(foo="hello"), Bar(bar=123)], many=True) Requires Python 3.11 or later. If marshmallow-oneofschema is installed alongside this package, set FASTONEOFSCHEMA_DISABLE_PTH=1 to avoid import redirection. Verify before relying: - Whether the performance improvements over the upstream marshmallow-oneofschema are measurable in typical workloads. - Stability and maturity of the DeepFriedMarshmallow plugin integration for production use. - Real-world compatibility with complex nested schema hierarchies beyond the documented examples. ## Package facts - License: Copyright 2016-2017 Maxim Kulkin Copyright 2018 Alex Rothberg and contributors Copyright 2024 Steven Loria and contributors Copyright 2025 Kalepa Permission is hereby granted, free of charge, to any… (full text in the JSON record) (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 194.6K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags polymorphic schema serialization, marshmallow oneofschema, type-based schema multiplexing, discriminated union serialization, marshmallow schema routing, serialization, polymorphic-types, schema-routing [View on SkillFed](https://skillfed.io/packages/marshmallow-fastoneofschema) · [View on PyPI](https://pypi.org/project/marshmallow-fastoneofschema/)