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

Apply schema in-place - thoughts? #336

Open
guyarad opened this issue May 7, 2018 · 3 comments
Open

Apply schema in-place - thoughts? #336

guyarad opened this issue May 7, 2018 · 3 comments

Comments

@guyarad
Copy link
Contributor

guyarad commented May 7, 2018

We really love this library and are using it extensively!

  1. I was wondering the rationale for strictly creating copies of the resulting schema. Where this is probably the best default behavior, it has some penalty in performance (when dealing with millions of objects). I haven't looked much into how can this be accomplished to avoid doing work that's not going to be incorporated back.

  2. Beyond performance, one of the side-effects of copying the validated object is instantiation of a new object of the same type. For us it creates a bit of an issue since we instantiate a dict-subclass object that requires parameters to create. One approach could be allowing specifying the type to instantiate. Another approach to solving this side-effect is enabling passing arguments for the instantiation.

Looking forward to your thoughts!

@alecthomas
Copy link
Owner

While I'm not specifically opposed to the idea, I'm not sure it could support both modes of operation without some serious ugliness. Have you tried prototyping an implementation?

@guyarad
Copy link
Contributor Author

guyarad commented May 8, 2018

If you aren't opposed I will experiment a little. I also suspect it won't be super easy, but since it's a big part of our project the performance increase could be significant for us. I will report back when I get a chance.

What about bullet 2 above? providing a different type for instantiating and/or providing args to pass to it?

@alecthomas
Copy link
Owner

BTW, have you profiled to confirm that copying is the dominant consumer?

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

No branches or pull requests

2 participants