New issue 1993: Slow string-to-byte encoding
https://bitbucket.org/pypy/pypy/issue/1993/slow-string-to-byte-encoding

mike fc:

Depending on versions being compared, pypy is 20x slower than CPython at string 
to byte encoding.
Using a pypy2 recent nightly and latest release pypy3 on OSX.


```
#!python

python      bytearray     buf.encode
python2.7.9    6.55          6.15
python3.4.2    0.55          0.19
pypy2         12.65         12.38
pypy3         10.7           5.99    
```



```
#!python
#!/usr/bin/env python
from __future__ import print_function
import time

buf = "hello there" * 220000
print(len(buf))

start = time.time()
for i in range(1000):
    p = bytearray(buf, 'ascii')
delta = time.time() - start
print("bytearray:", delta)

start = time.time()
for i in range(1000):
    p = buf.encode('ascii')
delta = time.time() - start
print("buf.encode:", delta)
```



_______________________________________________
pypy-issue mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-issue

Reply via email to