Re: [Python-Dev] Update on PEP 523 and adding a co_extra field to code objects

2016年8月30日 10:51:17 -0700

On 2016年8月30日 17:35:35 +0000
Brett Cannon <[email protected]> wrote:
> >
> > Perhaps a list would work indeed. Realistically, if there are at most
> > 2-3 users of the field at any given time (and most probably only one or
> > zero), a simple type check (by pointer equality) on each list item may
> > be sufficient.
> > 
> 
> Let's see what Maciej says, but we could standardize on switching the field
> to a list when a conflict of usage is detected so the common case in the
> frame eval function is checking for your own type, and if that fails then
> doing a PyList_CheckExact() and look for your object, otherwise make a list
> and move over to that for everyone to use. A little bit more code, but it's
> simple code and takes care of conflicts only when it calls for it.
That's a bit obscure and confusing, though (I *think* the weakref module
uses a similar kludge in some place). If you want to iterate on it you
have to write some bizarre macro to share the loop body between the two
different code-paths (list / non-list), or some equally tedious
function-pointer-based code.
Why not make it always a list? List objects are reasonably cheap in
memory and access time... (unlike dicts)
Regards
Antoine.
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to