[Python-Dev] PEP 435: pickling enums created with the functional API

Antoine Pitrou solipsis at pitrou.net
Tue May 7 18:14:24 CEST 2013


Le Tue, 7 May 2013 08:44:46 -0700,
Eli Bendersky <eliben at gmail.com> a écrit :
> >  > 4) Using _getframe(N) here seems like an overkill to me.
> >
> > It's not just overkill, it's fragile - it only works if you call the
> > constructor directly. If you use a convenience function in a utility
> > module, it will try to load your pickles from there rather than
> > wherever you bound the name.
> 
> In theory you can climb the frame stack until the desired place, but
> this is specifically what my proposal of adding a function tries to
> avoid.

I don't know how you could do it without walking the frame stack.
Granted, you don't need all the information that the stack holds
(you don't need to know about line numbers, instruction numbers
and local variables, for instance :-)), but you still have to walk
*some* kind of dynamically-created stack. This isn't something
that is solvable statically (as opposed to e.g. a class's __qualname__,
which is computed at compile-time).

Regards

Antoine.




More information about the Python-Dev mailing list