diff options
| author | Kevin Brown <kevin@kevinbrown.in> | 2014-07-13 17:29:58 -0400 |
|---|---|---|
| committer | Kevin Brown <kevin@kevinbrown.in> | 2014-07-13 17:29:58 -0400 |
| commit | 01e40b5e02e90ccac06e3b0ec0adf1f8f4e48ebd (patch) | |
| tree | e773b4abd6f35302f1cb3d4ca43337502383aede /gitdb/stream.py | |
| parent | b881134ec816d2a54f6e8deced8db25b4bd5baa7 (diff) | |
| download | gitdb-01e40b5e02e90ccac06e3b0ec0adf1f8f4e48ebd.tar.gz | |
Use memoryview instead of buffer
This uses memoryview by default, which is supported in Python 3
and Python 2.7, but not Python 2.6, and falls back to the old
`buffer` type in Python 2.6 and when the memoryview does not
support the type, such as when mmap instaces are passed in.
Diffstat (limited to 'gitdb/stream.py')
| -rw-r--r-- | gitdb/stream.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gitdb/stream.py b/gitdb/stream.py index 52b54af..a099eeb 100644 --- a/gitdb/stream.py +++ b/gitdb/stream.py @@ -270,7 +270,10 @@ class DecompressMemMapReader(LazyMixin): # END adjust winsize # takes a slice, but doesn't copy the data, it says ... - indata = buffer(self._m, self._cws, self._cwe - self._cws) + try: + indata = memoryview(self._m)[self._cws:self._cwe].tobytes() + except (NameError, TypeError): + indata = buffer(self._m, self._cws, self._cwe - self._cws) # get the actual window end to be sure we don't use it for computations self._cwe = self._cws + len(indata) |
