osdir.com

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

syntax difference


Bart wrote:
>    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.

That's true, but they're also extremely limited compared to
the things you can do with Python sets. They're really two
quite different things, designed for different use cases.

Compact sets of integers are possible in Python, but not
as a built-in type. This suggests that they're not needed
much -- if they were used a lot, they would have become
part of the stdlib by now.

-- 
Greg