[issue40411] frozen collection.Counter

Vedran Čačić report at bugs.python.org
Tue Apr 28 00:12:29 EDT 2020


Vedran Čačić <vedgar at gmail.com> added the comment:

Just another usecase: one of my students is writing an implementation of ordinal arithmetic in Python as a graduate thesis. FrozenCounters whose keys are FrozenCounters and whose values are natural numbers are _exactly_ isomorphic (via Cantor's normal form) to countable ordinals below epsilon_0 (and if a Counter can have itself as a key, we can go above epsilon_0 too).

Examples: zero = f{}
          one = f{zero: 1}
          seven = f{zero: 7}
          omega = f{one: 1}
          w^7*3+5 = f{seven: 3, zero: 5}
          w^w^w = f{f{omega: 1}: 1}
          epsilon0 = f{epsilon0: 1}
          and so on

I realize this is not something everybody does, but just to show that the need exists. We started with https://github.com/tamuhey/python-frozen-counter, afterwards we rolled our own implementation. But if it were in the stdlib, it would have saved us a lot of work.

----------
nosy: +veky

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40411>
_______________________________________


More information about the Python-bugs-list mailing list