Set vs. frozenset performance

前端 未结 2 1708
时光取名叫无心
时光取名叫无心 2020-12-08 19:13

I was tinkering around with Python\'s set and frozenset collection types.

Initially, I assumed that frozenset would provide a

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 19:31

    The reason for the two different datatypes is not for performance, it is functional. Because frozensets are immutable they can be used as a key in dictionaries. Sets cannot be used for this purpose.

提交回复
热议问题