-
-
Notifications
You must be signed in to change notification settings - Fork 594
Description
Hey,
So I've been using jsonschema for basic json validation of events before processing. However, one thing that I've noticed is that urlparse and urljoin are consistently among the hot spots in my code base. After tracing it down I've found that a lot of it comes from RefResolver.resolving and RefResolver.resolving.
It seems like a couple of optimizations could be really handy:
@contextlib.contextmanager
def resolving(self, ref):
if ref == '#':
yield self.store[self.base_uri]
else:
...
I'm not entirely sure how to go about handling in_scope, but in my application it seems like resolution scope always becomes the raw scope.
@contextlib.contextmanager
def in_scope(self, scope):
old_scope = self.resolution_scope
self.resolution_scope = scope
try:
yield
finally:
self.resolution_scope = old_scope
The next spot that seems to take up a bunch of time is in iter_errors. There aren't any validation errors, but this seems like it's just a matter of applying the schema to the object and detecting any errors. However, in several places it seems like it's wrapped in a list, which means you lose the ability to grab the first error and bail out.