|
|
Subscribe / Log in / New account

What benefit i get from frozensets?

What benefit i get from frozensets?

Posted Jan 19, 2022 6:24 UTC (Wed) by dambacher (subscriber, #1710)
Parent article: Python sets, frozensets, and literals

In my python coding I almost never actively used sets or even frozensets.
Even the given example of indirect usage via an "a in {b,c}" expression was never on my list.

So what use do I have from frozensets -
Are they faster on some accessing functions, e.g. "in"?
Do they use less memory?


to post comments

What benefit i get from frozensets?

Posted Jan 19, 2022 7:04 UTC (Wed) by LtWorf (subscriber, #124958) [Link]

Well I use frozenset but never used other features.

Sets automatically remove duplicates and have operations such as intersection and subtraction. In general when you use the "in" operator and don't care about ordering, you should always be using a set.

Frozensets are not mutable so, can be used as default parameter to functions, can be used inside other (frozen)set.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds