Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite0b0bec

Browse files
committed
Restore compatibility to python 3.0 to 3.4
1 parentc1998a0 commite0b0bec

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

‎doc/source/changes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
Changelog
33
#########
44

5+
**********
6+
v0.8.5
7+
**********
8+
- Fixed Python 3.0-3.3 regression, which also causes smmap to become about 3 times slower depending on the code path. It's related to this bug (http://bugs.python.org/issue15958), which was fixed in python 3.4
9+
510
**********
611
v0.8.4
712
**********

‎smmap/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
__author__="Sebastian Thiel"
44
__contact__="byronimo@gmail.com"
55
__homepage__="https://github.com/Byron/smmap"
6-
version_info= (0,8,4)
6+
version_info= (0,8,5)
77
__version__='.'.join(str(i)foriinversion_info)
88

99
# make everything available in root package for convenience

‎smmap/buf.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
__all__= ["SlidingWindowMapBuffer"]
55

6+
importsys
7+
68
try:
79
bytes
810
exceptNameError:
@@ -79,16 +81,31 @@ def __getslice__(self, i, j):
7981
ofs=i
8082
# It's fastest to keep tokens and join later, especially in py3, which was 7 times slower
8183
# in the previous iteration of this code
82-
md=list()
83-
whilel:
84-
c.use_region(ofs,l)
85-
assertc.is_valid()
86-
d=c.buffer()[:l]
87-
ofs+=len(d)
88-
l-=len(d)
89-
md.append(d)
90-
# END while there are bytes to read
91-
returnbytes().join(md)
84+
pyvers=sys.version_info[:2]
85+
if (3,0)<=pyvers<= (3,3):
86+
# Memory view cannot be joined below python 3.4 ...
87+
out=bytes()
88+
whilel:
89+
c.use_region(ofs,l)
90+
assertc.is_valid()
91+
d=c.buffer()[:l]
92+
ofs+=len(d)
93+
l-=len(d)
94+
# This is slower than the join ... but what can we do ...
95+
out+=d
96+
# END while there are bytes to read
97+
returnout
98+
else:
99+
md=list()
100+
whilel:
101+
c.use_region(ofs,l)
102+
assertc.is_valid()
103+
d=c.buffer()[:l]
104+
ofs+=len(d)
105+
l-=len(d)
106+
md.append(d)
107+
# END while there are bytes to read
108+
returnbytes().join(md)
92109
# END fast or slow path
93110
#{ Interface
94111

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp