4 ms·
Python has had enums [1] since Python 3.4 (2014). You can easily convert back and forth between enum values and their string and numeric values. I don't know a
by quietbritishjim 5y ago
Python has had enums [1] since Python 3.4 (2014). You can easily convert back and forth between enum values and their string and numeric values.
I don't know anything about Ruby or Erlang so I don't know if that's really relevant, just your comment seems to imply it doesn't.
[1] https://docs.python.org/3/library/enum.html https://docs.python.org/3/library/enum.html
- rkangel 5y agoYes, that's fair. I suppose I was describing my process of "discovery" and learning with Python which was significantly before 2014. Even now though, enums are not usually the normal way of doing things in public APIs, but that's presumably at least in part because of the history.
- nerdponx 5y agoAlso, unlike Ruby, string literals are usually interned in CPython (I think below a certain size), so they have at least some of the performance benefits of symbols in Ruby.