marshmallow-polyfield
An unofficial extension to Marshmallow to allow for polymorphic fields
Decision gist · record as of 2026-08-14
Yes, if you are already using Marshmallow 3.0+ and need polymorphic field support. The package is permissively licensed, has no external dependencies, and is stable for its intended use. However, it has been dormant since 2022-10-26 with no active maintenance—install only if you can tolerate potential incompatibilities with future Marshmallow releases.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Marshmallow 3.0 or above; requires Python >= 3.5.
- You must define both serialization_schema_selector and deserialization_schema_selector functions.
- High install friction; no runtime dependencies but the package has been dormant since 2022-10-26 (over 1388 days without release).
License · maintenance · safety
Apache 2.0 (permissive) — Licensed under Apache 2.0 (permissive), allowing commercial and private use with minimal restrictions. No license-based barriers to adoption.
last release 2022-10-26 (1388 days) · last repo commit 2024-07-01 · 59 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 174,935 downloads/mo, #10,275 on PyPI
Alternatives
Verify before relying
pip install marshmallow-polyfield
from marshmallow_polyfield import PolyField
from marshmallow import Schema
class MySchema(Schema):
field = PolyField(
serialization_schema_selector=my_serializer,
deserialization_schema_selector=my_deserializer
)- Whether the package works correctly with recent Marshmallow versions given the long maintenance gap.
- Whether critical bugs would receive fixes under current maintenance status.
- Compatibility with Python versions beyond 3.7 (classifiers only list up to 3.7).
What it is and what it does
Marshmallow-Polyfield is an unofficial extension to Marshmallow that adds support for polymorphic fields—fields that can hold objects of different types and serialize/deserialize them appropriately. Instead of defining a single schema for a field, you provide two selector functions: one that examines an object during serialization and returns the correct schema, and another that examines incoming data during deserialization and returns the correct schema. This allows you to handle heterogeneous data structures where a single field might contain different object types that each need their own serialization logic.
The package integrates with Marshmallow's standard field properties like `required`, `allow_none`, and `many`, so polymorphic fields behave like any other Marshmallow field in your schema. It targets Marshmallow 3.0 and above and supports Python >= 3.5. The package has no external runtime dependencies beyond Marshmallow itself.
Use it for
- Serialize REST API responses where a single field holds different object types.
- Build schemas for heterogeneous collections where each item's schema depends on its type.
- Handle polymorphic data in JSON APIs where type discrimination is based on attributes.
- Implement type-aware serialization in inheritance hierarchies with custom per-type handling.
- Deserialize incoming data by inspecting its structure to determine which schema to apply.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you are already using Marshmallow 3.0+ and need polymorphic field support.
The package is permissively licensed, has no external dependencies, and is stable for its intended use. However, it has been dormant since 2022-10-26 with no active maintenance—install only if you can tolerate potential incompatibilities with future Marshmallow releases.
Install
marshmallow-polyfield on PyPI
Before you install
High install friction; no runtime dependencies but the package has been dormant since 2022-10-26 (over 1388 days without release). Last commit was 2024-07-01. Suitable for projects already committed to Marshmallow 3.0+ that can tolerate lack of active maintenance.
Requires Marshmallow 3.0 or above; requires Python >= 3.5. You must define both serialization_schema_selector and deserialization_schema_selector functions.
License in practice
Licensed under Apache 2.0 (permissive), allowing commercial and private use with minimal restrictions. No license-based barriers to adoption.
Quickstart
pip install marshmallow-polyfield
from marshmallow_polyfield import PolyField
from marshmallow import Schema
class MySchema(Schema):
field = PolyField(
serialization_schema_selector=my_serializer,
deserialization_schema_selector=my_deserializer
)
Verify before relying
- Whether the package works correctly with recent Marshmallow versions given the long maintenance gap.
- Whether critical bugs would receive fixes under current maintenance status.
- Compatibility with Python versions beyond 3.7 (classifiers only list up to 3.7).
Package facts
| License | Apache 2.0 permissive |
| Python support | Supports the current Python release >=3.5 |
| Install friction | High. Source build required |
| Runtime dependencies | None |
| Maintenance | Dormant 1,388 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 174,935 / month, #10,275 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Intended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy |
Evidence: marshmallow-polyfield-5.11.tar.gz
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “polymorphic serialization marshmallow”
- marshmallow-polyfieldExtends Marshmallow with a PolyField class that handles serialization…
- marshmallow-oneofschemaExtends marshmallow to handle polymorphic serialization and…
- marshmallow-fastoneofschemaExtends marshmallow to handle polymorphic schema (de)serialization by…
Give your agent the search over MCP, or paste the wish link into any chat.
More Application Frameworks packages
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Textual is a Python framework for building cross-platform user interfaces that run in the terminal or web browser using a modern, component-based API.
Install it if you're developing CLI tools, dashboards, or interactive terminal applications.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Build and connect to Model Context Protocol servers that expose tools, resources, and prompts to LLM applications over stdio, HTTP, or SSE transports.
Install it if you need to build or connect to servers.
Werkzeug is a WSGI utility library providing request/response objects, URL routing, an interactive debugger, HTTP utilities, and a development server for building web applications.
See also marshmallow-oneofschema · marshmallow-union · marshmallow-fastoneofschema · marshmallow · marshmallow-enum · apispec-oneofschema · marshmallow-mongoengine · flask-marshmallow · DeepFriedMarshmallow · marshmallow-jsonapi