开发者

What's the most efficient way of intersecting to collections in Python?

开发者 https://www.devze.com 2023-02-20 04:29 出处:网络
I\'m new in python, sorry if there\'s anything wrong. I\'d like to intersect several collections (20 o 30) with a big amount of elements in them.

I'm new in python, sorry if there's anything wrong.

I'd like to intersect several collections (20 o 30) with a big amount of elements in them.

I've been reading and know that Sets are similar to hashtables (work with the same principle). Sets has the intersect method,开发者_JAVA技巧 i've been trying it and works really fine.

But, would like to have an experienced opinion.

What would you do?

The problem again. 20 or 30 collections (can be set, the elements are not repeated) and want to make intersection of them. Don't think how the collections are created (i.e. the insertion doesn't matters)

Thanks a lot!


result = set1.intersection(set2, set3, set4, ...)

http://docs.python.org/library/stdtypes.html

0

精彩评论

暂无评论...
验证码 换一张
取 消