-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Need to rewrite cython extensions in pure C #97
Comments
Update.
|
Given that python had now agreed to guarantee insertion order for standards dicts in python 3.6+ can't multidict just use a states standard dictionary not a list as it's core datastructures and improve performance? |
Sure, the library can be reimplemented by borrowing CPython compact dict ideas but it is another level of complication (need a C level coding anyway). Assuming that usual HTTP headers count is limited (10-30-50 at least) the sequential scan is as fast as hash table lookup, everything should fit into CPU cache. The current problem is Python |
Makes sense, I was wondering if you could use a dict to avoid sequential scan but I see that it might not make much difference. |
Duplicate of #249 |
The reason is
multidict.add(key, val)
is ten times slower thandict[key] = val
.This is because multidict stores data internally as a list of cythonized
_Item
objects.But creation of python (ever cythonized) object is too expensive for our use case.
The solution is using C structs for internal data but Cython has no support for visiting values stored in these structures:
tp_visit
andtp_clear
slots.Thus for sake of speed we need pure C implementation.
The text was updated successfully, but these errors were encountered: