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

Quote classes #155

Merged
merged 29 commits into from
Jan 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b0f8b49
Calc str len once, use PyUnicode_ReadChar
asvetlov Jan 11, 2018
7dc67b7
_hex -> _to_hex
asvetlov Jan 11, 2018
124c5e2
Use strict string type check
asvetlov Jan 11, 2018
e11c529
Implement fastpath
asvetlov Jan 11, 2018
bbd2370
Add new benchmark
asvetlov Jan 11, 2018
7933ac2
Refactoring
asvetlov Jan 11, 2018
2c22196
Compile cython on every source change
asvetlov Jan 11, 2018
a7b65e7
Implement fast path for already encoded PCT
asvetlov Jan 11, 2018
e1c1836
Code polishing
asvetlov Jan 11, 2018
3e79ea0
Add test for PCT fast path
asvetlov Jan 11, 2018
bedca1e
Drop never executed code
asvetlov Jan 11, 2018
d48a400
Update CHANGES
asvetlov Jan 11, 2018
8b449b2
Raise exception on unicode errors
asvetlov Jan 11, 2018
f932a9a
Drop unused variables
asvetlov Jan 11, 2018
09f70fe
Dont convert a char to str for UTF-8 encoding
asvetlov Jan 11, 2018
5532182
Dont duplicate safe chars by protected ones
asvetlov Jan 11, 2018
11cb598
Use lookup table for safe characters
asvetlov Jan 11, 2018
4f8835c
Use lookup table for protected characters
asvetlov Jan 11, 2018
3136b64
Switch to bitsets
asvetlov Jan 11, 2018
c01164b
Rewrite quoting tests
asvetlov Jan 11, 2018
3051259
Convert to quoter/unquoter usage
asvetlov Jan 11, 2018
575dc86
Classify everything
asvetlov Jan 11, 2018
38f2f97
Merge branch 'master' into quote_clases
asvetlov Jan 11, 2018
9a2d6dc
Remove last _quote usage
asvetlov Jan 11, 2018
29b20be
Inline contant
asvetlov Jan 11, 2018
2647fc3
Code cleanup
asvetlov Jan 11, 2018
d3fd752
Drop unused params
asvetlov Jan 11, 2018
81ff95b
Code cleanup
asvetlov Jan 11, 2018
a6c6e24
Code cleanup 2
asvetlov Jan 11, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ CHANGES

* Use fast path if quoted string does not need requoting (#154)

* Speed up quoting/unquoting by `_Quoter` and `_Unquoter` classes (#155)

* Drop `yarl.quote` and `yarl.unquote` public functions (#155)

0.18.0 (2018-01-10)
-------------------

Expand Down
32 changes: 20 additions & 12 deletions benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,51 @@


cython_setup = """\
from yarl.quoting import _quote as quote
from yarl.quoting import _unquote as unquote
from yarl.quoting import _Quoter as Quoter
from yarl.quoting import _Unquoter as Unquoter
"""

python_setup = """\
from yarl.quoting import _py_quote as quote
from yarl.quoting import _py_unquote as unquote
from yarl.quoting import _PyQuoter as Quoter
from yarl.quoting import _PyUnquoter as Unquoter
"""


print("Cython quote ascii: {:.3f} sec".format(
timeit.timeit("quote(s, safe='/')", cython_setup+"s='/path/to'")))
timeit.timeit("q(s)",
cython_setup+"s='/path/to';q=Quoter(safe='/')")))


print("Python quote ascii: {:.3f} sec".format(
timeit.timeit("quote(s, safe='/')", python_setup+"s='/path/to'")))
timeit.timeit("q(s)",
python_setup+"s='/path/to';q=Quoter(safe='/')")))


print("Cython quote PCT: {:.3f} sec".format(
timeit.timeit("quote(s)", cython_setup+"s='abc%0a'")))
timeit.timeit("q(s)",
cython_setup+"s='abc%0a';q=Quoter()")))


print("Python quote PCT: {:.3f} sec".format(
timeit.timeit("quote(s)", python_setup+"s='abc%0a'")))
timeit.timeit("q(s)",
python_setup+"s='abc%0a';q=Quoter()")))


print("Cython quote: {:.3f} sec".format(
timeit.timeit("quote(s)", cython_setup+"s='/путь/файл'")))
timeit.timeit("q(s)",
cython_setup+"s='/путь/файл';q=Quoter()")))


print("Python quote: {:.3f} sec".format(
timeit.timeit("quote(s)", python_setup+"s='/путь/файл'")))
timeit.timeit("q(s)",
python_setup+"s='/путь/файл';q=Quoter()")))


print("Cython unquote: {:.3f} sec".format(
timeit.timeit("unquote(s)", cython_setup+"s='/path/to'")))
timeit.timeit("u(s)",
cython_setup+"s='/path/to';u=Unquoter()")))


print("Python unquote: {:.3f} sec".format(
timeit.timeit("unquote(s)", python_setup+"s='/path/to'")))
timeit.timeit("u(s)",
python_setup+"s='/path/to';u=Unquoter()")))
Loading