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]

The complexity ends up being about the longer of list a or b. if they are over 
some thousands the speed difference with set() operations becomes significant. 
There are some details about naming, unique values (not necessary), and sort 
order that would probably need to be ironed out if they were to be included 
with the built in list type. I'm not qualified to do that work but I'd be happy 
to help.

Best Regards,
Richard Higginbotham
_______________________________________________
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/HSXJEPQQZGRLRACW6JWY4HRFMOAFGLUB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to