[Python-ideas] Change magic strings to enums

Antoine Pitrou solipsis at pitrou.net
Thu Apr 26 04:42:06 EDT 2018


On Thu, 26 Apr 2018 08:38:43 +0100
Ivan Levkivskyi <levkivskyi at gmail.com>
wrote:
> On 25 April 2018 at 12:01, Serhiy Storchaka <storchaka-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote:
> 
> > 25.04.18 13:15, Ivan Levkivskyi пише:
> >  
> >> Hm, this is what I wanted to know. I think by rewriting EnumMeta in C we
> >> can reduce the creation time of an Enum class
> >> (almost) down to the creation time of a normal class, which may be a 4-5x
> >> speed-up. What do you think?
> >>  
> >
> > It could be great. But I afraid this may add too much complexity in C
> > code. Maybe try to implement a simple and fast Enum for using it in the
> > stdlib and extend it with a richer interface in the enum module?
> >
> >  
> I think we can do something similar to ABCMeta, i.e. the metaclass itself
> will stay defined in Python, but the "hottest" parts of its methods will be
> replaced with helper functions written in C.

It's still a PITA to maintain, and it's not nice to Ethan (the main
enum maintainer) if suddenly he has to act on C code when he wants to
fix a bug or add a feature.

Regards

Antoine.




More information about the Python-ideas mailing list