A sets algorithm

Oscar Benjamin oscar.j.benjamin at gmail.com
Sun Feb 7 17:03:16 EST 2016


On 7 Feb 2016 21:51, "Paulo da Silva" <p_s_d_a_s_i_l_v_a_ns at netcabo.pt>
wrote:
>
> Hello!
>
> This may not be a strict python question, but ...
>
> Suppose I have already a class MyFile that has an efficient method (or
> operator) to compare two MyFile s for equality.
>
> What is the most efficient way to obtain all sets of equal files (of
> course each set must have more than one file - all single files are
> discarded)?

If you can make the MyFiles hashable then this is easily done with
defaultdict(list).

--
Oscar


More information about the Python-list mailing list