[Python-Dev] Pure pickle bechmark.
MRAB
python at mrabarnett.plus.com
Sun Jul 9 12:12:28 EDT 2017
On 2017-07-09 15:08, Bhavishya wrote:
> Hello,
>
> 1).I was going through the code of *python pickle* to search any
> optimization possibility.But the only thing that I found very alarming
> was again the import time(I tried with lazy-import but it didn't helped
> much.)
>
> I found py3 to be ~45 times slower on*initial imports(very raw
> measure..using "time." ) *as compared to py2 on an usual example.
>
> py3->
> ./python -c '
> favorite_color = { "lion": "yellow", "kitty": "red" }
> pickle.dump( favorite_color, open( "save.p", "wb" ) )'
> 0.009715557098388672(time taken to do initial imports...measured using
> *time.time()* )
>
> py2->
> ./python -c '
> favorite_color = { "lion": "yellow", "kitty": "red" }
> pickle.dump( favorite_color, open( "save.p", "wb" ) )'
> 0.000236034393311(time taken to do initial imports...measured using
> *time.time()* )
>
> Do you have any thought/ideas on improving this?
>
Python 3 is using Unicode strings, whereas Python 2 is using bytestrings.
What you show above are very short (in time) examples (less than 1/100
of a second), so they're not that meaningful.
If you had timed pickling a substantial object (the same object in both
cases) and it took a significant amount of time and you found a
significant slowdown, then it would be worth looking into further.
More information about the Python-Dev
mailing list