skillfed

marshmallow-fastoneofschema

fast marshmallow multiplexing schema

marshmallow-fastoneofschema v2025.9.2.1.dev7 194.6K downloads/30d#9,831 on PyPI1
Permissive 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) AGING released

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 on this page — 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

marshmallow-fastoneofschema on PyPI

pip

pip install marshmallow-fastoneofschema

uv

uv add marshmallow-fastoneofschema

poetry

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 the current Python release (>=3.11)
Install friction low — pure-Python wheel
Runtime dependencies 1 — marshmallow
Maintenance aging — 346 days since the last release
Last repo commit
First released
Downloads 194,570/month — #9,831 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: marshmallow_fastoneofschema-2025.9.2.1.dev7-py3-none-any.whl

Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13

Tags

polymorphic schema serializationmarshmallow oneofschematype-based schema multiplexingdiscriminated union serializationmarshmallow schema routing
serializationpolymorphic-typesschema-routing

More Software Development packages