Finding set difference between ranges

Neil Cerutti neilc at norwich.edu
Wed Apr 18 11:09:38 EDT 2018


On 2018-04-18, tejaswi prakash <tejaswidprakash at gmail.com> wrote:
> Hello all,
> I have 3 continuous (steps of 1) ranges a,a1,a2. All of them sorted.
> I am performing the following operations on them
>
> a = a.difference (a1)
> a = a.difference(a2)

If they are each stored as a set I don't see how they can be
sorted. Are you converting to set and then calling difference?

It may still be more efficient than writing your own loop to take
advantage of the sorted status of the original objects.

-- 
Neil Cerutti



More information about the Python-list mailing list