[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-24 Thread Larry Hastings


On 12/23/19 8:09 PM, Kyle Stanley wrote:


Chris Angelico wrote:
> I think this is an artifact of Python not having an empty set literal.
> [snip]
> When both use the constructor call or both use a literal, the
> difference is far smaller. I'd call this one a wash.

Ah, good catch. I hadn't considered that it would make a substantial 
difference, but that makes sense. Here's an additional comparison 
between "{}"  and "dict()" to confirm it:


>>> timeit.timeit("{}", number=100_000_000)
2.1038335599987477
>>> timeit.timeit("dict()", number=100_000_000)
10.22558353268



We could also go the other way with it, set / dict-map-to-dontcare with 
one element, because that way we /can/ have a set literal:


>>> timeit.timeit("set()", number=100_000_000)
   8.579900023061782
>>> timeit.timeit("dict()", number=100_000_000)
   10.473437276901677
>>> timeit.timeit("{0}", number=100_000_000)
   5.969995185965672
>>> timeit.timeit("{0:0}", number=100_000_000)
   6.24465325800702

(ran all four of those just so you see a relative sense on my laptop, 
which I guess is only slghtly slower than Kyle's)



Happy holidays,


//arry/

___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/MQAKLPKWECT22NVPRITAD5XQBIFUS4UA/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-24 Thread Wes Turner
A table with these columns might be helpful for performance comparisons: [
structure,
operation,
big_o,
keyset,  # signed ints, randstrs
timeit_output,
system_load,
architecture,  # x86_84, aarch64
os,
]

Does anyone have a recommendation for a tool that stores such benchmark
data in JSON and merges the e.g. per-arch output?

Are there URIs for Big-O notation that could be added as e.g. structured
attributes in docstrings or annotations?

I just added a ._repr_html_() method to the tabulate package so that, in
addition to the many excellent ASCII formats tabulate prints,
tabulate.tabulate(data, tablefmt='html') displays an html-escaped table in
Jupyter notebooks? It's not yet released, so you'd need to
 `pip install -e git+
https://github.com/astanin/python-tabulate@master#egg=tabulate`

On Tue, Dec 24, 2019, 3:53 AM Larry Hastings  wrote:

>
> On 12/23/19 8:09 PM, Kyle Stanley wrote:
>
>
> Chris Angelico wrote:
> > I think this is an artifact of Python not having an empty set literal.
> > [snip]
> > When both use the constructor call or both use a literal, the
> > difference is far smaller. I'd call this one a wash.
>
> Ah, good catch. I hadn't considered that it would make a substantial
> difference, but that makes sense. Here's an additional comparison between
> "{}"  and "dict()" to confirm it:
>
> >>> timeit.timeit("{}", number=100_000_000)
> 2.1038335599987477
> >>> timeit.timeit("dict()", number=100_000_000)
> 10.22558353268
>
>
> We could also go the other way with it, set / dict-map-to-dontcare with
> one element, because that way we *can* have a set literal:
>
> >>> timeit.timeit("set()", number=100_000_000)
> 8.579900023061782
> >>> timeit.timeit("dict()", number=100_000_000)
> 10.473437276901677
> >>> timeit.timeit("{0}", number=100_000_000)
> 5.969995185965672
> >>> timeit.timeit("{0:0}", number=100_000_000)
> 6.24465325800702
>
> (ran all four of those just so you see a relative sense on my laptop,
> which I guess is only slghtly slower than Kyle's)
>
>
> Happy holidays,
>
>
> */arry*
> ___
> Python-Dev mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/[email protected]/message/MQAKLPKWECT22NVPRITAD5XQBIFUS4UA/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/6OWPRNUXCK776G5H53RAP3OPHBNMK6D7/
Code of Conduct: http://python.org/psf/codeofconduct/