So I ran the tests with both a list and a tuple.  They were about 5% slower on 
a handful of benchmarks, and then the difference between the tuple and list 
again had a few benchmarks that were around 5% slower.  There was one benchmark 
where the tuple one significantly for some reason (mako_v2) which was 1.4x 
slower.  It seems to me we should go with the tuple just because the common 
case will be having a single object and it'll be even less common to have these 
changing very frequently.

-----Original Message-----
From: Python-Dev [mailto:python-dev-bounces+dinov=microsoft....@python.org] On 
Behalf Of Chris Angelico
Sent: Tuesday, August 30, 2016 2:11 PM
To: python-dev <python-dev@python.org>
Subject: Re: [Python-Dev] Update on PEP 523 and adding a co_extra field to code 
objects

On Wed, Aug 31, 2016 at 4:55 AM, Serhiy Storchaka <storch...@gmail.com> wrote:
> On 30.08.16 21:20, Antoine Pitrou wrote:
>>
>> On Tue, 30 Aug 2016 18:12:01 +0000
>> Brett Cannon <br...@python.org> wrote:
>>>>
>>>> Why not make it always a list?  List objects are reasonably cheap 
>>>> in memory and access time... (unlike dicts)
>>>
>>>
>>> Because I would prefer to avoid any form of unnecessary performance 
>>> overhead for the common case.
>>
>>
>> But the performance overhead of iterating over a 1-element list is 
>> small enough (it's just an array access after a pointer dereference) 
>> that it may not be larger than the overhead of the multiple tests and 
>> conditional branches your example shows.
>
>
> Iterating over a tuple is even faster. It needs one pointer 
> dereference less.
>
> And for memory efficiency we can use just a raw array of pointers.

Didn't all this kind of thing come up when function annotations were discussed? 
Insane schemes like dictionaries with UUID keys and so on.
The decision then was YAGNI. The decision now, IMO, should be the same. Keep 
things simple.

ChrisA
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fmail.python.org%2fmailman%2flistinfo%2fpython-dev&data=01%7c01%7cdinov%40microsoft.com%7c9d750b06b2134a2145c708d3d11a4ab0%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=szub1gsDW2rdns3IQGV68J3tCqWiNcjqG77xYIfoORc%3d
Unsubscribe: 
https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fmail.python.org%2fmailman%2foptions%2fpython-dev%2fdinov%2540microsoft.com&data=01%7c01%7cdinov%40microsoft.com%7c9d750b06b2134a2145c708d3d11a4ab0%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=TEzMSyJLmAe2BVZGPugXAh6bga2xN1WQw3bR0z0b%2fLg%3d
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
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