
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Implementation of Immutable Sorted Set collection.
You can get it by downloading it directly or by typing:
$ pip install SortedSet
After it is installed you can import it by typing:
>>> from SortedSet.sorted_set import SortedSet
As for the usage it is as simple as:
>>> SortedSet(['list_of_integer_data'])
For example
>>> SortedSet([1, 2, 5, 3, 3, 1])
Would return the following
SortedSet([1, 2, 3, 5])
You can add two SortedSets together either by using '+' operator, calling .union() method on one of the sets and providing the other, or by using union operator '|'.
Take for example these two SortedSets
>>> a = SortedSet([1, 2, 5, 3])
>>> b = SortedSet([2, 4, 6])
We could add them together by running any of these commands
>>> a + b
>>> a.union(b)
>>> a | b
In all three cases the result would be the SortedSet
SortedSet([1, 2, 3, 4, 5, 6])
You can subtract two SortedSets either calling .difference() method on one of the sets and providing the other, or by using difference operator '-'. Be aware that ordering of SortedSets matters.
Take for example the same two SortedSets we already used
>>> a = SortedSet([1, 2, 5, 3])
>>> b = SortedSet([2, 4, 6])
We can subtract them by running one of these two commands
>>> a - b
>>> a.difference(b)
In both cases the result would be the SortedSet
SortedSet([1, 3, 5])
If we were to switch the order of the operands
>>> b - a
>>> b.difference(a)
We would get entirely different result
SortedSet([4, 6])
You can find unique members that are only contained in one of the two SortedSets either by calling .symmetric_difference() method on one of the sets and providing the other, or by using symmetric difference operator '^'.
>>> a = SortedSet([1, 2, 5, 3])
>>> b = SortedSet([2, 4, 6])
>>> a.symmetric_difference(b)
SortedSet([1, 3, 4, 5, 6])
>>> b ^ a
SortedSet([1, 3, 4, 5, 6])
You can find unique members that are contained in both of the two SortedSets either by calling .intersection() method on one of the sets and providing the other, or by using intersection operator '&'.
>>> a = SortedSet([1, 2, 5, 3])
>>> b = SortedSet([2, 4, 6])
>>> a.intersection(b)
SortedSet([2])
>>> b & a
SortedSet([2])
It is also possible to check if one SortedSet is a superset or subset of another either by using .issuperset() and .issubset() methods or by using operators '>=' and '<='.
>>> a = SortedSet([1, 2])
>>> b = SortedSet([1, 2, 3])
>>> a.issuperset(b)
False
>>> a >= b
False
>>> a.issubset(b)
True
>>> a <= b
True
You can find out are two SortedSets disjoint, meaning that they have no common members by running .isdisjoint() method on one of the SortedSets.
>>> a = SortedSet([1, 3])
>>> b = SortedSet([6, 4, 8])
>>> a.isdisjoint(b)
True
>>> a = SortedSet([4, 3])
>>> b = SortedSet([6, 4, 8])
>>> b.isdisjoint(a)
False
Other supported operations are:
len() contains() comparison of two SortedSets for equality or inequality access to SortedSet members by their index
>>> a = SortedSet([1, 3, 7, 5])
>>> len(a)
4
/>>> a.contains(1)
True
>>> a.contains(31)
False
>>> b = SortedSet([2, 3])
>>> a == b
False
>>> c = SortedSet([3, 1, 5, 7])
>>> a == c
True
>>> a != b
True
>>> a[0]
1
>>> b[1]
3
FAQs
Implementation of Immutable Sorted Set collection
We found that SortedSet demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.