<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Fri, 2 Sep 2016 at 13:31 Dino Viehland via Python-Dev <<a href="mailto:python-dev@python.org">python-dev@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">So it looks like both list and tuple are about within 5% of using co_extra directly. Using a tuple instead of a list is about a wash except for make_v2 where list is 1.4x slower for some reason (which I didn't dig into).<br>
<br>
I would say that using a tuple and copying the tuple on updates makes sense as we don't expect these to change very often and we don't expect collisions to happen very often.<br></blockquote><div><br></div><div>So would making co_extra a PyTupleObject instead of PyObject alleviate people's worry of a collision problem? You're going to have to hold the GIL anyway to interact with the tuple so there won't be any race condition in replacing the tuple when it's grown (or initially set).</div><div><br></div><div>-Brett</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> -----Original Message-----<br>
> From: Python-Dev [mailto:<a href="mailto:python-dev-" target="_blank">python-dev-</a><br>
> bounces+dinov=<a href="mailto:microsoft.com@python.org" target="_blank">microsoft.com@python.org</a>] On Behalf Of Chris Angelico<br>
> Sent: Tuesday, August 30, 2016 2:11 PM<br>
> To: python-dev <<a href="mailto:python-dev@python.org" target="_blank">python-dev@python.org</a>><br>
> Subject: Re: [Python-Dev] Update on PEP 523 and adding a co_extra field to<br>
> code objects<br>
><br>
> On Wed, Aug 31, 2016 at 4:55 AM, Serhiy Storchaka <<a href="mailto:storchaka@gmail.com" target="_blank">storchaka@gmail.com</a>><br>
> wrote:<br>
> > On 30.08.16 21:20, Antoine Pitrou wrote:<br>
> >><br>
> >> On Tue, 30 Aug 2016 18:12:01 +0000<br>
> >> Brett Cannon <<a href="mailto:brett@python.org" target="_blank">brett@python.org</a>> wrote:<br>
> >>>><br>
> >>>> Why not make it always a list? List objects are reasonably cheap<br>
> >>>> in memory and access time... (unlike dicts)<br>
> >>><br>
> >>><br>
> >>> Because I would prefer to avoid any form of unnecessary performance<br>
> >>> overhead for the common case.<br>
> >><br>
> >><br>
> >> But the performance overhead of iterating over a 1-element list is<br>
> >> small enough (it's just an array access after a pointer dereference)<br>
> >> that it may not be larger than the overhead of the multiple tests and<br>
> >> conditional branches your example shows.<br>
> ><br>
> ><br>
> > Iterating over a tuple is even faster. It needs one pointer<br>
> > dereference less.<br>
> ><br>
> > And for memory efficiency we can use just a raw array of pointers.<br>
><br>
> Didn't all this kind of thing come up when function annotations were<br>
> discussed? Insane schemes like dictionaries with UUID keys and so on.<br>
> The decision then was YAGNI. The decision now, IMO, should be the same.<br>
> Keep things simple.<br>
><br>
> ChrisA<br>
> _______________________________________________<br>
> Python-Dev mailing list<br>
> <a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
> <a href="https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fmail.pyt" rel="noreferrer" target="_blank">https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fmail.pyt</a><br>
> <a href="http://hon.org" rel="noreferrer" target="_blank">hon.org</a>%2fmailman%2flistinfo%2fpython-<br>
> dev&data=01%7c01%7cdinov%<a href="http://40microsoft.com" rel="noreferrer" target="_blank">40microsoft.com</a>%7c9d750b06b2134a2145c70<br>
> 8d3d11a4ab0%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=szub1gs<br>
> DW2rdns3IQGV68J3tCqWiNcjqG77xYIfoORc%3d<br>
> Unsubscribe:<br>
> <a href="https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fmail.pyt" rel="noreferrer" target="_blank">https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fmail.pyt</a><br>
> <a href="http://hon.org" rel="noreferrer" target="_blank">hon.org</a>%2fmailman%2foptions%2fpython-<br>
> dev%2fdinov%<a href="http://2540microsoft.com" rel="noreferrer" target="_blank">2540microsoft.com</a>&data=01%7c01%7cdinov%<a href="http://40microsoft.co" rel="noreferrer" target="_blank">40microsoft.co</a><br>
> m%7c9d750b06b2134a2145c708d3d11a4ab0%7c72f988bf86f141af91ab2d7c<br>
> d011db47%7c1&sdata=TEzMSyJLmAe2BVZGPugXAh6bga2xN1WQw3bR0z0b<br>
> %2fLg%3d<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/brett%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/brett%40python.org</a><br>
</blockquote></div></div>