[Python-ideas] enums vs symbols

Guido van Rossum guido at python.org
Tue Feb 12 22:58:04 CET 2013


I don't know Ruby symbols, but if they are anything like Lisp symbols,
they are completely different. Lisp symbols are interned strings --
Python just uses strings (and if they happen to be interned you get a
modest speedup). This is for things like:

if hasattr(x, 'foo'):
    x.foo()

On Tue, Feb 12, 2013 at 1:55 PM,  <ryan at ryanhiebert.com> wrote:
> Forgive me, a lurker, but I wonder: how does an enum differ in usage from something like a Symbol from ruby, other than that an enum is required to be declared beforehand?
>
> I'm definitely a python guy, but the idea of identifiers that are their own value interests me, and seems like it could have some overlap with the concept and usage of enums.
>
> If there's not much difference in usage between enums and symbols apart from declaration, perhaps we could make the declaration optional and combine the concepts? This would certainly require parser changes.
>
> Ryan
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas



--
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list