However if you want to iterate documents you have to consider which post has a priority, I assume it's p1. If you want to intersect IDs from posts ( credits to James) do: common_ids = p1.keys() & p2.keys() Your question isn't precise enough to give single answer. If you are trying to get these gains looking at a different language or Cython might be better. I tested both passing in the pre-calculated list outside of the timings and within the timings, and, while it's statistically significant, it's less than 30 μs and 10 μs respectively. NB: I did test using the pre-calculated list of ems() for the for a dictionary instead of v2's building the generator on the fly. The regression for result dict_lst1 is mainly due to difference in overhead between creating a dictionary after every intersection and the overhead due to ems() calls within the generator (and python's general function call overhead). of 7 runs, 100 loops each)Ĥ.88 ms ± 5.31 µs per loop (mean ± std. of 7 runs, 10000 loops each)ĩ.08 ms ± 22 µs per loop (mean ± std. of 7 runs, 10000 loops each)Ģ5.1 µs ± 131 ns per loop (mean ± std. A little known fact is that you don't need to construct sets to do this: Python 3 d1 = for n in range(400)]Ĩ08 ns ± 4.31 ns per loop (mean ± std.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |