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

Optimization #85

Merged
merged 20 commits into from
Jun 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
3.0.0 (xxxx-xx-xx)
------------------

* Refactor internal data structures: main dict operations are about
100% faster now.


2.1.7 (2017-05-29)
------------------

* Fix import warning on Python 3.6 #79

2.1.6 (2017-05-27)
------------------

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ cov cover coverage:

cov-dev: .develop rmcache
pytest --cov=multidict --cov-report=term --cov-report=html tests
@echo "open file://`pwd`/coverage/index.html"
@echo "open file://`pwd`/htmlcov/index.html"

cov-dev-full: .develop rmcache
AIOHTTPMULTIDICT_NO_EXTENSIONS=1 pytest --cov=multidict --cov-append tests
pytest --cov=multidict --cov-report=term --cov-report=html tests
@echo "open file://`pwd`/coverage/index.html"
@echo "open file://`pwd`/htmlcov/index.html"

clean:
rm -rf `find . -name __pycache__`
Expand Down
40 changes: 21 additions & 19 deletions benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,36 +53,38 @@
val = upstr('VaLuE')
"""

print("Cython setitem str: {:.3f} sec".format(
timeit.timeit(setitem, cython_multidict+fill)))
gc.collect()
print("Cython / Python / x")

print("Python setitem str: {:.3f} sec".format(
timeit.timeit(setitem, python_multidict+fill)))
t1 = timeit.timeit(setitem, cython_multidict+fill)
gc.collect()
t2 = timeit.timeit(setitem, python_multidict+fill)
gc.collect()

print("MD.setitem str: {:.3f}s {:3f}s {:1f}x".format(t1, t2, t2/t1))

print("Cython getitem str: {:.3f} sec".format(
timeit.timeit(getitem, cython_multidict+fill)))
gc.collect()

print("Python getitem str: {:.3f} sec".format(
timeit.timeit(getitem, python_multidict+fill)))
t1 = timeit.timeit(getitem, cython_multidict+fill)
gc.collect()
t2 = timeit.timeit(getitem, python_multidict+fill)
gc.collect()

print("MD.getitem str: {:.3f}s {:3f}s {:1f}x".format(t1, t2, t2/t1))

print("Cython getitem upstr: {:.3f} sec".format(
timeit.timeit(getitem, cython_cimultidict+fill)))
gc.collect()

print("Python getitem upstr: {:.3f} sec".format(
timeit.timeit(getitem, python_cimultidict+fill)))
t1 = timeit.timeit(getitem, cython_cimultidict+fill)
gc.collect()
t2 = timeit.timeit(getitem, python_cimultidict+fill)
gc.collect()
print("CI.getitem str: {:.3f}s {:3f}s {:1f}x".format(t1, t2, t2/t1))

print("Cython upstr from upstr: {:.3f} sec".format(
timeit.timeit(upstr_from_upstr, cython_cimultidict+make_upstr)))
t1 = timeit.timeit(getitem, cython_cimultidict+fill_upstr)
gc.collect()
t2 = timeit.timeit(getitem, python_cimultidict+fill_upstr)
gc.collect()
print("CI.getitem istr: {:.3f}s {:3f}s {:1f}x".format(t1, t2, t2/t1))

print("Python upstr from upstr: {:.3f} sec".format(
timeit.timeit(upstr_from_upstr, python_cimultidict+make_upstr)))
t1 = timeit.timeit(upstr_from_upstr, cython_cimultidict+make_upstr)
gc.collect()
t2 = timeit.timeit(upstr_from_upstr, python_cimultidict+make_upstr)
gc.collect()
print("istr from istr: {:.3f}s {:3f}s {:1f}x".format(t1, t2, t2/t1))
2 changes: 1 addition & 1 deletion multidict/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
__all__ = ('MultiDictProxy', 'CIMultiDictProxy',
'MultiDict', 'CIMultiDict', 'upstr', 'istr')

__version__ = '2.1.6'
__version__ = '2.1.7'


if bool(os.environ.get('MULTIDICT_NO_EXTENSIONS')):
Expand Down
Loading