On Thu, Sep 19, 2019 at 03:26:27PM +1000, Chris Angelico wrote:
> On Thu, Sep 19, 2019 at 3:08 PM Richard Higginbotham <higgi...@gmail.com> 
> wrote:
> >
> > I'm not sure if there is any interest by others but I have frequently come 
> > across cases where I would like to compare items in one list in another 
> > similar to relational algebra. For example are the file names in A in B and 
> > if so return a new list with those items. Long story short, I wrote some 
> > functions to do that. They are quite simple and fast (due to timsort in no 
> > small part). Even the plain python code is faster than the built in set 
> > functions (afaik). I created a github and put the ones I thought the 
> > community might like in there. https://github.com/ponderpanda/listex
> >
> > an example would be
> > a = [1,2,3,4,5,6]
> > b = [1,3,7,4]
> > list_intersection(a,b, sorta=True, sortb=True)
> >
> > returns [1,3,4]
> 
> Can you elaborate on how this differs from using the built-in set type
> for set operations? eg is this for situations where the values are not
> all hashable?

Sets are unordered and can contain no duplicates. Lists are ordered and 
can contain duplicates, so you might think of them as "ordered 
multisets".

I can't say I'm very enthusiastic about that "sorta, sortb" API, and I'm 
rather surprised about Richard's claim that a pure-Python list 
intersection is faster than set intersection written in C (but maybe 
Richard is a better programmer than me). But I'd like to hear more about 
this proposal.



-- 
Steven
_______________________________________________
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/IVC4345635ZE366CRZQEQPGX4LQD5WC6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to