[Python-Dev] Guarantee ordered dict literals in v3.7?

Chris Angelico rosuav at gmail.com
Mon Nov 6 05:48:37 EST 2017


On Mon, Nov 6, 2017 at 9:36 PM, Stefan Krah <stefan at bytereef.org> wrote:
> On Mon, Nov 06, 2017 at 12:18:17PM +0200, Paul Sokolovsky wrote:
>> MicroPython hashmap implementation is effectively O(n) (average and
>> worst case) due to the algorithm parameters chosen (like the load factor
>> of 1). Of course, parameters could be tweaked, but the ones chosen are
>> so because the memory usage is far more important for MicroPython
>> systems than performance characteristics (all due to small amounts of
>> memory). Like, MicroPython was twice as fast than Python 3.3 on
>> average, and 1000 times more efficient in the memory usage.
>
> $ cat xxx.py
>
> def pi_float():
>     """native float"""
>     lasts, t, s, n, na, d, da = 0, 3.0, 3, 1, 0, 0, 24
>     while s != lasts:
>         lasts = s
>         n, na = n+na, na+8
>         d, da = d+da, da+32
>         t = (t * n) / d
>         s += t
>     return s
>
> for i in range(100000):
>     x = pi_float()
>
> $ time ./micropython xxx.py
>
> real    0m4.424s
> user    0m4.406s
> sys     0m0.016s
> $
> $ time ../../cpython/python xxx.py
>
> real    0m1.066s
> user    0m1.056s
> sys     0m0.010s
>
>
>
> Congratulations ...

Maybe I'm misreading your demo, but I fail to see what this has to do
with dict performance?

ChrisA


More information about the Python-Dev mailing list