[Python-Dev] 3.3 str timings

R. David Murray rdmurray at bitdance.com
Sun Aug 19 01:19:27 CEST 2012


On Sat, 18 Aug 2012 17:17:14 -0400, Terry Reedy <tjreedy at udel.edu> wrote:
> print(timeit("a.encode()", "a = 'a'*1000"))
> # 1.5 in 3.2, .26 in 3.3
> 
> print(timeit("a.encode(encoding='utf-8')", "a = 'a'*1000"))
> # 1.7 in 3.2, .51 in 3.3
> 
> This is one of the 3.3 improvements. But since the results are equal:
> ('a'*1000).encode() == ('a'*1000).encode(encoding='utf-8')
> and 3.3 should know that for an all-ascii string, I do not see why 
> adding the parameter should double the the time. Another issue or known 
> and un-fixable?

At one point there was an issue with certain spellings taking a fast path
(avoiding a codec lookup?) and other spellings not.  I thought we'd fixed
that, but perhaps we didn't?

--David


More information about the Python-Dev mailing list