Skip to content

Comments

Add support for DeepFriedMarshmallow#328

Draft
illusional wants to merge 1 commit intomasterfrom
support-deepfriedmarshmallow
Draft

Add support for DeepFriedMarshmallow#328
illusional wants to merge 1 commit intomasterfrom
support-deepfriedmarshmallow

Conversation

@illusional
Copy link
Contributor

@illusional illusional commented Feb 3, 2026

DeepFriedMarshmallow is a drop-in JIT for Marshmallow, but some nested objects don't handle the deepcopy well. We can preempt this by subverting the deepcopy with a shallow copy (through reinstantiation).

It supports marshmallow = ">=3.13.0,<5.0.0"

...
  File "/Users/franklm/source/leatherhead/.venv/lib/python3.12/site-packages/flask_rebar/swagger_generation/marshmallow_to_swagger.py", line 241, in get_items
    singular_obj = copy.deepcopy(obj)
                   ^^^^^^^^^^^^^^^^^^
  File "/Users/franklm/.pyenv/versions/3.12.7/lib/python3.12/copy.py", line 162, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/franklm/.pyenv/versions/3.12.7/lib/python3.12/copy.py", line 259, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/franklm/.pyenv/versions/3.12.7/lib/python3.12/copy.py", line 136, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/Users/franklm/.pyenv/versions/3.12.7/lib/python3.12/copy.py", line 221, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/franklm/.pyenv/versions/3.12.7/lib/python3.12/copy.py", line 162, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/franklm/.pyenv/versions/3.12.7/lib/python3.12/copy.py", line 260, in _reconstruct
    if hasattr(y, '__setstate__'):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/franklm/source/leatherhead/.venv/lib/python3.12/site-packages/deepfriedmarshmallow/serializer.py", line 63, in __getattr__
    return getattr(self._method, item)
                   ^^^^^^^^^^^^
  File "/Users/franklm/source/leatherhead/.venv/lib/python3.12/site-packages/deepfriedmarshmallow/serializer.py", line 63, in __getattr__
    return getattr(self._method, item)
                   ^^^^^^^^^^^^
  File "/Users/franklm/source/leatherhead/.venv/lib/python3.12/site-packages/deepfriedmarshmallow/serializer.py", line 63, in __getattr__
    return getattr(self._method, item)
                   ^^^^^^^^^^^^
  [Previous line repeated 971 more times]
RecursionError: maximum recursion depth exceeded

@illusional
Copy link
Contributor Author

Ah, because marshmallow fields are sorted in marshmallow 4, the list comparison fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant