On Sep 19, 2019, at 15:18, Richard Musil <risa20...@gmail.com> wrote:
> 
> Ok, I misread the original code, the lists were not sorted in the previous 
> results (and their should be). So with the correction to have them sorted,

I think to be fair, you want to show it _both_ ways, just as you’re showing 
sets both with and without creating the sets. Because sometimes you’re already 
going to have sorted lists, just as sometimes you’re already going to have sets.

So there are four things to compare:

    * set operation on existing sets
    * set operation including time to build the sets
    * step-compare operation on pre-sorted lists
    * step-compare including time to sort the lists

(Also, for the set operation, there’s no need to build _two_ sets. Just build a 
set of one and intersect it with the other list.)

Anyway, from your two separate results, it looks like:

 * If you have sets, set operations are faster. 
 * If you have unsorted lists, set operations are faster.
 * If you have sorted lists, the times are a lot closer, and may vary in a 
nonobvious way, so if it matters, you probably want to profile with your actual 
data and the specific operation you need.

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/UFTSKUJREVZOJOWMLNN4PYPUTWRXPXIH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to