Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Add a class Meta option to prevent adding a class to the internal registry #660

Closed
sloria opened this issue Jul 21, 2017 · 3 comments · Fixed by #1079
Closed

Comments

@sloria
Copy link
Member

sloria commented Jul 21, 2017

Purpose

Implement a way to bypass marshmallow's internal class registry when it isn't necessary in order to optimize memory usage.

Proposed API

class MyNonRegisteredSchema(Schema):
    class Meta:
        register = False
@lafrech
Copy link
Member

lafrech commented Apr 3, 2018

In this comment, @jtillman argues that registration could default to False.

Referring to a Schema by its name as string is a common use case, a feature that a user may have to use before he gets much experience, so having this working by default, and without scattering the code with Meta classes, is nice. Therefore I'd say let's keep registration at True by default.

This memory usage issue is a pitfall for users with more advanced needs. Hopefully, we can assume
those user should have read a bit of documentation and an explicit warning pointing to this feature should be enough.

This is totally arguable and I don't have a strong opinion either way.

@sloria
Copy link
Member Author

sloria commented Apr 6, 2018

Referring to a Schema by its name as string is a common use case, a feature that a user may have to use before he gets much experience, so having this working by default, and without scattering the code with Meta classes, is nice. Therefore I'd say let's keep this at False.

Isn't this an argument to default to True?

@lafrech
Copy link
Member

lafrech commented Apr 6, 2018

Oh, right, sorry. I got mixed up and wrote exactly the opposite of what I was thinking. I fixed my comment.

@sloria sloria added this to the 3.0 milestone Dec 27, 2018
sloria added a commit that referenced this issue Dec 27, 2018
Useful when memory usage is critical.

close #660
@lafrech lafrech mentioned this issue Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants