Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit da0a610

Browse files
committed
Remove buffer
1 parent 341b278 commit da0a610

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

smmap/mman.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
MapRegion,
55
MapRegionList,
66
is_64_bit,
7-
buffer,
87
)
98

109
import sys
@@ -160,7 +159,7 @@ def buffer(self):
160159
161160
**Note:** buffers should not be cached passed the duration of your access as it will
162161
prevent resources from being freed even though they might not be accounted for anymore !"""
163-
return buffer(self._region.buffer(), self._ofs, self._size)
162+
return memoryview(self._region.buffer())[self._ofs:self._ofs+self._size]
164163

165164
def map(self):
166165
"""

smmap/util.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,11 @@
55
from mmap import mmap, ACCESS_READ
66
from mmap import ALLOCATIONGRANULARITY
77

8-
__all__ = ["align_to_mmap", "is_64_bit", "buffer",
8+
__all__ = ["align_to_mmap", "is_64_bit",
99
"MapWindow", "MapRegion", "MapRegionList", "ALLOCATIONGRANULARITY"]
1010

1111
#{ Utilities
1212

13-
try:
14-
# Python 2
15-
buffer = buffer
16-
except NameError:
17-
# Python 3 has no `buffer`; only `memoryview`
18-
def buffer(obj, offset, size):
19-
# Actually, for gitpython this is fastest ... .
20-
return memoryview(obj)[offset:offset+size]
21-
# doing it directly is much faster !
22-
# return obj[offset:offset + size]
23-
2413

2514
def align_to_mmap(num, round_up):
2615
"""

0 commit comments

Comments
 (0)