faster and simpler bytes implementation
parent
ed13f7c47d
commit
31e6afc7cf
|
@ -8,17 +8,10 @@ import six # Python 2+3 compatibility
|
||||||
|
|
||||||
def bytes(s,i,j=None):
|
def bytes(s,i,j=None):
|
||||||
"""implements s[i], s[i:], s[i:j] for Python2 and Python3"""
|
"""implements s[i], s[i:], s[i:j] for Python2 and Python3"""
|
||||||
if six.PY2:
|
if i<0 : i=len(s)+i
|
||||||
if j is None:
|
if j is None: j=i+1
|
||||||
return s[i]
|
if j<0 : j=len(s)
|
||||||
if j<0:
|
return s[i:j]
|
||||||
return s[i:]
|
|
||||||
return s[i:j]
|
|
||||||
else: # six.PY3
|
|
||||||
if i<0 : i=len(s)+i
|
|
||||||
if j is None: j=i+1
|
|
||||||
if j<0 : j=len(s)
|
|
||||||
return b''.join(six.int2byte(s[_]) for _ in range(i,j))
|
|
||||||
|
|
||||||
from .utils import choplist
|
from .utils import choplist
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue