syntax difference

Chris Angelico rosuav at gmail.com
Tue Jun 26 07:39:24 EDT 2018


On Tue, Jun 26, 2018 at 9:30 PM, Bart <bc at freeuk.com> wrote:
> On 19/06/2018 11:33, Steven D'Aprano wrote:
>>
>> On Tue, 19 Jun 2018 10:19:15 +0100, Bart wrote:
>
>
>> * Integer sets (Pascal-like sets)
>>
>> Why do you need them if you have real sets?
>
>
> I tried Python sets for the first time. They seemed workable but rather
> clunky to set up. But here is one problem on my CPython:
>
>    x = set(range(10_000_000))
>
> This used up 460MB of RAM (the original 100M I tried exhausted the memory).
>
> The advantage of Pascal-style sets is that that same set will occupy only
> 1.25MB, as it is a bit-map.
>
> While sets will not usually be that big, there might be lots of small sets
> and they all add up.

Cool. Make me a bitset that can represent this Python set:

{-5, -4, 6, 10, 1.5, "spam", print}

ChrisA



More information about the Python-list mailing list