| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ed3ecbb commit 54a34e8
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,6 @@ | |||
| 1 | 1 | language: python | |
| 2 | 2 | python: | |
| 3 | - # These versions are unsupported by travis, even though smmap claims to still support these outdated versions | ||
| 4 | - # - 2.4 | ||
| 5 | - # - 2.5 | ||
| 6 | - - 2.6 | ||
| 7 | 3 | - 2.7 | |
| 8 | - - 3.3 | ||
| 9 | 4 | - 3.4 | |
| 10 | 5 | - 3.5 | |
| 11 | 6 | install: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,6 @@ Although memory maps have many advantages, they represent a very limited system | |||
| 9 | 9 | ||
| 10 | 10 | * **System resources (file-handles) are likely to be leaked!** This is due to the library authors reliance on a deterministic `__del__()` destructor. | |
| 11 | 11 | * The memory access is read-only by design. | |
| 12 | - * In python below 2.6, memory maps will be created in compatibility mode which works, but creates inefficient memory mappings as they always start at offset 0. | ||
| 13 | 12 | ||
| 14 | 13 | ||
| 15 | 14 | ## Overview | |
@@ -34,7 +33,7 @@ For performance critical 64 bit applications, a simplified version of memory map | |||
| 34 | 33 | ||
| 35 | 34 | ## Prerequisites | |
| 36 | 35 | ||
| 37 | - * Python 2.4, 2.5, 2.6, 2.7 or 3.3 | ||
| 36 | + * Python 2.7 or 3.4+ | ||
| 38 | 37 | * OSX, Windows or Linux | |
| 39 | 38 | ||
| 40 | 39 | The package was tested on all of the previously mentioned configurations. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,7 +22,7 @@ For performance critical 64 bit applications, a simplified version of memory map | |||
| 22 | 22 | ############# | |
| 23 | 23 | Prerequisites | |
| 24 | 24 | ############# | |
| 25 | - * Python 2.4, 2.5, 2.6, 2.7 or 3.3 | ||
| 25 | + * Python 2.7 or 3.4+ | ||
| 26 | 26 | * OSX, Windows or Linux | |
| 27 | 27 | ||
| 28 | 28 | The package was tested on all of the previously mentioned configurations. | |
@@ -31,7 +31,6 @@ The package was tested on all of the previously mentioned configurations. | |||
| 31 | 31 | Limitations | |
| 32 | 32 | ########### | |
| 33 | 33 | * The memory access is read-only by design. | |
| 34 | - * In python below 2.6, memory maps will be created in compatibility mode which works, but creates inefficient memory mappings as they always start at offset 0. | ||
| 35 | 34 | ||
| 36 | 35 | ################ | |
| 37 | 36 | Installing smmap | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,12 +13,12 @@ | |||
| 13 | 13 | if os.path.exists("README.md"): | |
| 14 | 14 | long_description = codecs.open('README.md', "r", "utf-8").read() | |
| 15 | 15 | else: | |
| 16 | - long_description = "See http://github.com/gitpython-developers/smmap" | ||
| 16 | + long_description = "See https://github.com/gitpython-developers/smmap" | ||
| 17 | 17 | ||
| 18 | 18 | setup( | |
| 19 | 19 | name="smmap2", | |
| 20 | 20 | version=smmap.__version__, | |
| 21 | - description="A pure python implementation of a sliding window memory map manager", | ||
| 21 | + description="A pure Python implementation of a sliding window memory map manager", | ||
| 22 | 22 | author=smmap.__author__, | |
| 23 | 23 | author_email=smmap.__contact__, | |
| 24 | 24 | url=smmap.__homepage__, | |
@@ -45,10 +45,8 @@ | |||
| 45 | 45 | "Operating System :: MacOS :: MacOS X", | |
| 46 | 46 | "Programming Language :: Python", | |
| 47 | 47 | "Programming Language :: Python :: 2", | |
| 48 | - "Programming Language :: Python :: 2.6", | ||
| 49 | 48 | "Programming Language :: Python :: 2.7", | |
| 50 | 49 | "Programming Language :: Python :: 3", | |
| 51 | - "Programming Language :: Python :: 3.3", | ||
| 52 | 50 | "Programming Language :: Python :: 3.4", | |
| 53 | 51 | "Programming Language :: Python :: 3.5", | |
| 54 | 52 | "Programming Language :: Python :: 3.6", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -88,35 +88,20 @@ def __getslice__(self, i, j): | |||
| 88 | 88 | # It's fastest to keep tokens and join later, especially in py3, which was 7 times slower | |
| 89 | 89 | # in the previous iteration of this code | |
| 90 | 90 | pyvers = sys.version_info[:2] | |
| 91 | - if (3, 0) <= pyvers <= (3, 3): | ||
| 92 | - # Memory view cannot be joined below python 3.4 ... | ||
| 93 | - out = bytes() | ||
| 94 | - while l: | ||
| 95 | - c.use_region(ofs, l) | ||
| 96 | - assert c.is_valid() | ||
| 97 | - d = c.buffer()[:l] | ||
| 98 | - ofs += len(d) | ||
| 99 | - l -= len(d) | ||
| 100 | - # This is slower than the join ... but what can we do ... | ||
| 101 | - out += d | ||
| 102 | - del(d) | ||
| 103 | - # END while there are bytes to read | ||
| 104 | - return out | ||
| 105 | - else: | ||
| 106 | - md = list() | ||
| 107 | - while l: | ||
| 108 | - c.use_region(ofs, l) | ||
| 109 | - assert c.is_valid() | ||
| 110 | - d = c.buffer()[:l] | ||
| 111 | - ofs += len(d) | ||
| 112 | - l -= len(d) | ||
| 113 | - # Make sure we don't keep references, as c.use_region() might attempt to free resources, but | ||
| 114 | - # can't unless we use pure bytes | ||
| 115 | - if hasattr(d, 'tobytes'): | ||
| 116 | - d = d.tobytes() | ||
| 117 | - md.append(d) | ||
| 118 | - # END while there are bytes to read | ||
| 119 | - return bytes().join(md) | ||
| 91 | + md = list() | ||
| 92 | + while l: | ||
| 93 | + c.use_region(ofs, l) | ||
| 94 | + assert c.is_valid() | ||
| 95 | + d = c.buffer()[:l] | ||
| 96 | + ofs += len(d) | ||
| 97 | + l -= len(d) | ||
| 98 | + # Make sure we don't keep references, as c.use_region() might attempt to free resources, but | ||
| 99 | + # can't unless we use pure bytes | ||
| 100 | + if hasattr(d, 'tobytes'): | ||
| 101 | + d = d.tobytes() | ||
| 102 | + md.append(d) | ||
| 103 | + # END while there are bytes to read | ||
| 104 | + return bytes().join(md) | ||
| 120 | 105 | # END fast or slow path | |
| 121 | 106 | #{ Interface | |
| 122 | 107 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,13 +3,7 @@ | |||
| 3 | 3 | import sys | |
| 4 | 4 | ||
| 5 | 5 | from mmap import mmap, ACCESS_READ | |
| 6 | - try: | ||
| 7 | - from mmap import ALLOCATIONGRANULARITY | ||
| 8 | - except ImportError: | ||
| 9 | - # in python pre 2.6, the ALLOCATIONGRANULARITY does not exist as it is mainly | ||
| 10 | - # useful for aligning the offset. The offset argument doesn't exist there though | ||
| 11 | - from mmap import PAGESIZE as ALLOCATIONGRANULARITY | ||
| 12 | - # END handle pythons missing quality assurance | ||
| 6 | + from mmap import ALLOCATIONGRANULARITY | ||
| 13 | 7 | ||
| 14 | 8 | __all__ = ["align_to_mmap", "is_64_bit", "buffer", | |
| 15 | 9 | "MapWindow", "MapRegion", "MapRegionList", "ALLOCATIONGRANULARITY"] | |
@@ -116,11 +110,6 @@ class MapRegion(object): | |||
| 116 | 110 | '_size', # cached size of our memory map | |
| 117 | 111 | '__weakref__' | |
| 118 | 112 | ] | |
| 119 | - _need_compat_layer = sys.version_info[:2] < (2, 6) | ||
| 120 | - | ||
| 121 | - if _need_compat_layer: | ||
| 122 | - __slots__.append('_mfb') # mapped memory buffer to provide offset | ||
| 123 | - # END handle additional slot | ||
| 124 | 113 | ||
| 125 | 114 | #{ Configuration | |
| 126 | 115 | #} END configuration | |
@@ -147,11 +136,6 @@ def __init__(self, path_or_fd, ofs, size, flags=0): | |||
| 147 | 136 | kwargs = dict(access=ACCESS_READ, offset=ofs) | |
| 148 | 137 | corrected_size = size | |
| 149 | 138 | sizeofs = ofs | |
| 150 | - if self._need_compat_layer: | ||
| 151 | - del(kwargs['offset']) | ||
| 152 | - corrected_size += ofs | ||
| 153 | - sizeofs = 0 | ||
| 154 | - # END handle python not supporting offset ! Arg | ||
| 155 | 139 | ||
| 156 | 140 | # have to correct size, otherwise (instead of the c version) it will | |
| 157 | 141 | # bark that the size is too large ... many extra file accesses because | |
@@ -161,10 +145,6 @@ def __init__(self, path_or_fd, ofs, size, flags=0): | |||
| 161 | 145 | # END handle memory mode | |
| 162 | 146 | ||
| 163 | 147 | self._size = len(self._mf) | |
| 164 | - | ||
| 165 | - if self._need_compat_layer: | ||
| 166 | - self._mfb = buffer(self._mf, ofs, self._size) | ||
| 167 | - # END handle buffer wrapping | ||
| 168 | 148 | finally: | |
| 169 | 149 | if isinstance(path_or_fd, string_types()): | |
| 170 | 150 | os.close(fd) | |
@@ -224,22 +204,6 @@ def release(self): | |||
| 224 | 204 | """Release all resources this instance might hold. Must only be called if there usage_count() is zero""" | |
| 225 | 205 | self._mf.close() | |
| 226 | 206 | ||
| 227 | - # re-define all methods which need offset adjustments in compatibility mode | ||
| 228 | - if _need_compat_layer: | ||
| 229 | - def size(self): | ||
| 230 | - return self._size - self._b | ||
| 231 | - | ||
| 232 | - def ofs_end(self): | ||
| 233 | - # always the size - we are as large as it gets | ||
| 234 | - return self._size | ||
| 235 | - | ||
| 236 | - def buffer(self): | ||
| 237 | - return self._mfb | ||
| 238 | - | ||
| 239 | - def includes_ofs(self, ofs): | ||
| 240 | - return self._b <= ofs < self._size | ||
| 241 | - # END handle compat layer | ||
| 242 | - | ||
| 243 | 207 | #} END interface | |
| 244 | 208 | ||
| 245 | 209 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | # and then run "tox" from this directory. | |
| 5 | 5 | ||
| 6 | 6 | [tox] | |
| 7 | - envlist = flake8, py26, py27, py33, py34 | ||
| 7 | + envlist = flake8, py27, py34 | ||
| 8 | 8 | ||
| 9 | 9 | [testenv] | |
| 10 | 10 | commands = nosetests {posargs:--with-coverage --cover-package=smmap} | |
| Back | FazBrowse Home | New Git URL |
0 commit comments