Skip to content

Commit 54a34e8

Browse files
hugovkByron
authored andcommitted
Drop support for EOL Python
1 parent ed3ecbb commit 54a34e8

File tree

7 files changed

+20
-80
lines changed

7 files changed

+20
-80
lines changed

.travis.yml

-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
language: python
22
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
73
- 2.7
8-
- 3.3
94
- 3.4
105
- 3.5
116
install:

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Although memory maps have many advantages, they represent a very limited system
99

1010
* **System resources (file-handles) are likely to be leaked!** This is due to the library authors reliance on a deterministic `__del__()` destructor.
1111
* 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.
1312

1413

1514
## Overview
@@ -34,7 +33,7 @@ For performance critical 64 bit applications, a simplified version of memory map
3433

3534
## Prerequisites
3635

37-
* Python 2.4, 2.5, 2.6, 2.7 or 3.3
36+
* Python 2.7 or 3.4+
3837
* OSX, Windows or Linux
3938

4039
The package was tested on all of the previously mentioned configurations.

doc/source/intro.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ For performance critical 64 bit applications, a simplified version of memory map
2222
#############
2323
Prerequisites
2424
#############
25-
* Python 2.4, 2.5, 2.6, 2.7 or 3.3
25+
* Python 2.7 or 3.4+
2626
* OSX, Windows or Linux
2727

2828
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.
3131
Limitations
3232
###########
3333
* 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.
3534

3635
################
3736
Installing smmap

setup.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
if os.path.exists("README.md"):
1414
long_description = codecs.open('README.md', "r", "utf-8").read()
1515
else:
16-
long_description = "See http://github.com/gitpython-developers/smmap"
16+
long_description = "See https://github.com/gitpython-developers/smmap"
1717

1818
setup(
1919
name="smmap2",
2020
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",
2222
author=smmap.__author__,
2323
author_email=smmap.__contact__,
2424
url=smmap.__homepage__,
@@ -45,10 +45,8 @@
4545
"Operating System :: MacOS :: MacOS X",
4646
"Programming Language :: Python",
4747
"Programming Language :: Python :: 2",
48-
"Programming Language :: Python :: 2.6",
4948
"Programming Language :: Python :: 2.7",
5049
"Programming Language :: Python :: 3",
51-
"Programming Language :: Python :: 3.3",
5250
"Programming Language :: Python :: 3.4",
5351
"Programming Language :: Python :: 3.5",
5452
"Programming Language :: Python :: 3.6",

smmap/buf.py

+14-29
Original file line numberDiff line numberDiff line change
@@ -88,35 +88,20 @@ def __getslice__(self, i, j):
8888
# It's fastest to keep tokens and join later, especially in py3, which was 7 times slower
8989
# in the previous iteration of this code
9090
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)
120105
# END fast or slow path
121106
#{ Interface
122107

smmap/util.py

+1-37
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33
import sys
44

55
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
137

148
__all__ = ["align_to_mmap", "is_64_bit", "buffer",
159
"MapWindow", "MapRegion", "MapRegionList", "ALLOCATIONGRANULARITY"]
@@ -116,11 +110,6 @@ class MapRegion(object):
116110
'_size', # cached size of our memory map
117111
'__weakref__'
118112
]
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
124113

125114
#{ Configuration
126115
#} END configuration
@@ -147,11 +136,6 @@ def __init__(self, path_or_fd, ofs, size, flags=0):
147136
kwargs = dict(access=ACCESS_READ, offset=ofs)
148137
corrected_size = size
149138
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
155139

156140
# have to correct size, otherwise (instead of the c version) it will
157141
# 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):
161145
# END handle memory mode
162146

163147
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
168148
finally:
169149
if isinstance(path_or_fd, string_types()):
170150
os.close(fd)
@@ -224,22 +204,6 @@ def release(self):
224204
"""Release all resources this instance might hold. Must only be called if there usage_count() is zero"""
225205
self._mf.close()
226206

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-
243207
#} END interface
244208

245209

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# and then run "tox" from this directory.
55

66
[tox]
7-
envlist = flake8, py26, py27, py33, py34
7+
envlist = flake8, py27, py34
88

99
[testenv]
1010
commands = nosetests {posargs:--with-coverage --cover-package=smmap}

0 commit comments

Comments
 (0)