[issue27575] dict viewkeys intersection slow for large dicts

Forest report at bugs.python.org
Wed Jun 13 10:50:45 EDT 2018


Forest <fgregg at gmail.com> added the comment:

Is there anything helpful I can do to help close this issue? Maybe convert it into a github PR?

Since Raymond asked for cases where this issue is a problem, I'll add the case that brought me here.

I have an application where I need to do thousands of intersections of multisets. I started with the collections.Counter object, but the current intersection method is too slow. As Counter is a subclass of dict, I thought that I could significantly speed it up by taking advantage of keys intersections.

I've been able to verify that if key intersection was roughly similar in speed to set intersection, than that would be very helpful. However, the   current speed of key intersection does not make that practicable. I can, of course, cast the keys to sets before intersecting, but as David points out that casting is what is taking significant time.




slow dictionary intersection for becoming larger dicts is becoming a problem for me

----------
nosy: +fgregg

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue27575>
_______________________________________


More information about the Python-bugs-list mailing list