Skip to content

Add Benchmarks & Split/Unroll-scopes optimizations (x1.6 faster) #182

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

Closed
12 changes: 8 additions & 4 deletions jsonschema/compat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from __future__ import unicode_literals
import sys

from collections import namedtuple
import operator
import sys


try:
from collections import MutableMapping, Sequence # noqa
Expand All @@ -13,7 +16,7 @@
zip = zip
from io import StringIO
from urllib.parse import (
unquote, urljoin, urlunsplit, SplitResult, urlsplit as _urlsplit
unquote, urljoin, urlunsplit, SplitResult, urlsplit as _urlsplit,
)
from urllib.request import urlopen
str_types = str,
Expand All @@ -23,7 +26,7 @@
from itertools import izip as zip # noqa
from StringIO import StringIO
from urlparse import (
urljoin, urlunsplit, SplitResult, urlsplit as _urlsplit # noqa
urljoin, urlunsplit, SplitResult, urlsplit as _urlsplit, # noqa
)
from urllib import unquote # noqa
from urllib2 import urlopen # noqa
Expand All @@ -40,14 +43,15 @@ def urlsplit(url):
return SplitResult(scheme, netloc, path, query, fragment)


DefragResult = namedtuple('DefragResult', 'url fragment')
def urldefrag(url):
if "#" in url:
s, n, p, q, frag = urlsplit(url)
defrag = urlunsplit((s, n, p, q, ''))
else:
defrag = url
frag = ''
return defrag, frag
return DefragResult(defrag, frag)


# flake8: noqa
Loading