You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I benchmarked a validation against a json input of roughly 700k characters, and it seems deepcopy of the checker is the costliest operation
get_validator relies on _get_format_checker
def _get_format_checker(self):
fc = deepcopy(oas30_format_checker)
for name, formatter in self.custom_formatters.items():
fc.checks(name)(formatter.validate)
return fc
The deepcopy of oas30_format_checker is where most of the time is spent. Can you help me understand why there is a need for deepcopy ?
The text was updated successfully, but these errors were encountered:
Hi @sjiekak
That's interesting. I wasn't aware of deepcopy slowness . This part of code is responsible for creation of format checker and I use oas30_format_checker for default formats and add custom ones with checks method. You need to get new object not the reference for that otherwise you will end up having custom formats inside default oas30_format_checker .
This can be problematic when you have more specs with different custom formats or when you use oas30_format_checker somewhere else.
I'm wondering if shallowed copy would be better here.
One more thing is you have high number of calls for copy which can be because of many requests.
Solution for that can be keeping reference to custom format checker and reusing it for each request.
I benchmarked a validation against a json input of roughly 700k characters, and it seems deepcopy of the checker is the costliest operation
get_validator
relies on_get_format_checker
The deepcopy of
oas30_format_checker
is where most of the time is spent. Can you help me understand why there is a need for deepcopy ?The text was updated successfully, but these errors were encountered: