diff options
| author | Sebastian Thiel <byronimo@gmail.com> | 2014-11-13 08:21:09 +0100 |
|---|---|---|
| committer | Sebastian Thiel <byronimo@gmail.com> | 2014-11-13 08:21:27 +0100 |
| commit | 948a9274527d14702875581d7115389cf9aa8244 (patch) | |
| tree | 4f5e5dcbd922deda608a6df0e9cff1f1df045530 | |
| parent | 977e666e2489ddc669a06481bb5192b59854da8d (diff) | |
| download | smmap-948a9274527d14702875581d7115389cf9aa8244.tar.gz | |
Fixed a few typos and major linter errors
| -rw-r--r-- | .travis.yml | 5 | ||||
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | doc/source/changes.rst | 2 | ||||
| -rw-r--r-- | doc/source/intro.rst | 8 | ||||
| -rwxr-xr-x[-rw-r--r--] | setup.py | 10 | ||||
| -rw-r--r-- | smmap/__init__.py | 2 | ||||
| -rw-r--r-- | smmap/buf.py | 2 | ||||
| -rw-r--r-- | smmap/mman.py | 16 | ||||
| -rw-r--r-- | smmap/test/test_buf.py | 14 | ||||
| -rw-r--r-- | smmap/test/test_mman.py | 12 | ||||
| -rw-r--r-- | smmap/test/test_util.py | 9 | ||||
| -rw-r--r-- | smmap/util.py | 4 |
12 files changed, 45 insertions, 43 deletions
diff --git a/.travis.yml b/.travis.yml index 1f7872c..cb0c16e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ language: python python: - - 2.4 - - 2.5 + # These versions are unsupported by travis, even though smmap claims to still support these outdated versions + # - 2.4 + # - 2.5 - 2.6 - 2.7 - 3.3 @@ -37,11 +37,9 @@ The package was tested on all of the previously mentioned configurations. ## Installing smmap -Its easiest to install smmap using the *easy_install* or *pip* program, which is part of the [setuptools](http://peak.telecommunity.com/DevCenter/setuptools) or [pip](http://www.pip-installer.org/en/latest) respectively: +Its easiest to install smmap using the [pip](http://www.pip-installer.org/en/latest) program: ```bash -$ easy_install smmap -# or $ pip install smmap ``` diff --git a/doc/source/changes.rst b/doc/source/changes.rst index 6174008..d5ed8e3 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -3,7 +3,7 @@ Changelog ######### ********** -v0.8.2 +v0.8.3 ********** - Cleaned up code and assured it works sufficiently well with python 3 diff --git a/doc/source/intro.rst b/doc/source/intro.rst index 30bff0d..ee3108a 100644 --- a/doc/source/intro.rst +++ b/doc/source/intro.rst @@ -22,7 +22,7 @@ For performance critical 64 bit applications, a simplified version of memory map ############# Prerequisites ############# -* Python 2.4, 2.5 or 2.6 +* Python 2.4, 2.5, 2.6, 2.7 or 3.3 * OSX, Windows or Linux The package was tested on all of the previously mentioned configurations. @@ -32,15 +32,12 @@ Limitations ########### * The memory access is read-only by design. * 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. -* It wasn't tested on python 2.7 and 3.x. ################ Installing smmap ################ -Its easiest to install smmap using the *easy_install* or *pip* program, which is part of the `setuptools`_ or `pip`_ respectively:: +Its easiest to install smmap using the *pip* program:: - $ easy_install smmap - # or $ pip install smmap As the command will install smmap in your respective python distribution, you will most likely need root permissions to authorize the required changes. @@ -75,5 +72,4 @@ License Information ################### *smmap* is licensed under the New BSD License. -.. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools .. _pip: http://www.pip-installer.org/en/latest/ @@ -10,10 +10,10 @@ except ImportError: import smmap -if os.path.exists("README.rst"): - long_description = codecs.open('README.rst', "r", "utf-8").read() +if os.path.exists("README.md"): + long_description = codecs.open('README.md', "r", "utf-8").read() else: - long_description = "See http://github.com/nvie/smmap/tree/master" + long_description = "See http://github.com/Byron/smmap" setup( name="smmap", @@ -32,8 +32,8 @@ setup( #"Development Status :: 1 - Planning", #"Development Status :: 2 - Pre-Alpha", #"Development Status :: 3 - Alpha", - "Development Status :: 4 - Beta", - #"Development Status :: 5 - Production/Stable", + # "Development Status :: 4 - Beta", + "Development Status :: 5 - Production/Stable", #"Development Status :: 6 - Mature", #"Development Status :: 7 - Inactive", "Environment :: Console", diff --git a/smmap/__init__.py b/smmap/__init__.py index 879ebea..c494648 100644 --- a/smmap/__init__.py +++ b/smmap/__init__.py @@ -3,7 +3,7 @@ __author__ = "Sebastian Thiel" __contact__ = "byronimo@gmail.com" __homepage__ = "https://github.com/Byron/smmap" -version_info = (0, 8, 2) +version_info = (0, 8, 3) __version__ = '.'.join(str(i) for i in version_info) # make everything available in root package for convenience diff --git a/smmap/buf.py b/smmap/buf.py index 4cde6dd..ef9d49e 100644 --- a/smmap/buf.py +++ b/smmap/buf.py @@ -1,6 +1,4 @@ """Module with a simple buffer implementation using the memory manager""" -from .mman import WindowCursor - import sys __all__ = ["SlidingWindowMapBuffer"] diff --git a/smmap/mman.py b/smmap/mman.py index a89efd4..da6fd81 100644 --- a/smmap/mman.py +++ b/smmap/mman.py @@ -101,7 +101,7 @@ class WindowCursor(object): :param flags: additional flags to be given to os.open in case a file handle is initially opened for mapping. Has no effect if a region can actually be reused. :return: this instance - it should be queried for whether it points to a valid memory region. - This is not the case if the mapping failed becaues we reached the end of the file + This is not the case if the mapping failed because we reached the end of the file **Note:**: The size actually mapped may be smaller than the given size. If that is the case, either the file has reached its end, or the map was created between two existing regions""" @@ -137,7 +137,7 @@ class WindowCursor(object): """Unuse the ucrrent region. Does nothing if we have no current region **Note:** the cursor unuses the region automatically upon destruction. It is recommended - to unuse the region once you are done reading from it in persistent cursors as it + to un-use the region once you are done reading from it in persistent cursors as it helps to free up resource more quickly""" self._region = None # note: should reset ofs and size, but we spare that for performance. Its not @@ -203,7 +203,7 @@ class WindowCursor(object): return self._rlist.file_size() def path_or_fd(self): - """:return: path or file decriptor of the underlying mapped file""" + """:return: path or file descriptor of the underlying mapped file""" return self._rlist.path_or_fd() def path(self): @@ -237,12 +237,12 @@ class StaticWindowMapManager(object): These clients would have to use a SlidingWindowMapBuffer to hide this fact. This type will always use a maximum window size, and optimize certain methods to - acomodate this fact""" + accommodate this fact""" __slots__ = [ '_fdict', # mapping of path -> StorageHelper (of some kind '_window_size', # maximum size of a window - '_max_memory_size', # maximum amount ofmemory we may allocate + '_max_memory_size', # maximum amount of memory we may allocate '_max_handle_count', # maximum amount of handles to keep open '_memory_size', # currently allocated memory size '_handle_count', # amount of currently allocated file handles @@ -264,7 +264,7 @@ class StaticWindowMapManager(object): If 0, the window may have any size, which basically results in mapping the whole file at one :param max_memory_size: maximum amount of memory we may map at once before releasing mapped regions. If 0, a viable default will be set depending on the system's architecture. - It is a soft limit that is tried to be kept, but nothing bad happens if we have to overallocate + It is a soft limit that is tried to be kept, but nothing bad happens if we have to over-allocate :param max_open_handles: if not maxint, limit the amount of open file handles to the given number. Otherwise the amount is only limited by the system itself. If a system or soft limit is hit, the manager will free as many handles as possible""" @@ -350,8 +350,6 @@ class StaticWindowMapManager(object): # As many more operations are likely to fail in that condition ( # like reading a file from disk, etc) we free up as much as possible # As this invalidates our insert position, we have to recurse here - # NOTE: The c++ version uses a linked list to curcumvent this, but - # using that in python is probably too slow anyway if is_recursive: # we already tried this, and still have no success in obtaining # a mapping. This is an exception, so we propagate it @@ -562,8 +560,6 @@ class SlidingWindowMapManager(StaticWindowMapManager): # As many more operations are likely to fail in that condition ( # like reading a file from disk, etc) we free up as much as possible # As this invalidates our insert position, we have to recurse here - # NOTE: The c++ version uses a linked list to curcumvent this, but - # using that in python is probably too slow anyway if is_recursive: # we already tried this, and still have no success in obtaining # a mapping. This is an exception, so we propagate it diff --git a/smmap/test/test_buf.py b/smmap/test/test_buf.py index 807d277..d3e51e2 100644 --- a/smmap/test/test_buf.py +++ b/smmap/test/test_buf.py @@ -1,14 +1,18 @@ -from __future__ import with_statement, print_function +from __future__ import print_function from .lib import TestBase, FileCreator -from smmap.mman import SlidingWindowMapManager, StaticWindowMapManager -from smmap.buf import * +from smmap.mman import ( + SlidingWindowMapManager, + StaticWindowMapManager + ) +from smmap.buf import SlidingWindowMapBuffer from random import randint from time import time import sys import os +import logging man_optimal = SlidingWindowMapManager() @@ -71,8 +75,8 @@ class TestBuf(TestBase): assert man_optimal.num_file_handles() == 1 # PERFORMANCE - # blast away with rnadom access and a full mapping - we don't want to - # exagerate the manager's overhead, but measure the buffer overhead + # blast away with random access and a full mapping - we don't want to + # exaggerate the manager's overhead, but measure the buffer overhead # We do it once with an optimal setting, and with a worse manager which # will produce small mappings only ! max_num_accesses = 100 diff --git a/smmap/test/test_mman.py b/smmap/test/test_mman.py index 4d1839e..cc5d914 100644 --- a/smmap/test/test_mman.py +++ b/smmap/test/test_mman.py @@ -1,11 +1,13 @@ -from __future__ import with_statement, print_function +from __future__ import print_function from .lib import TestBase, FileCreator -from smmap.mman import * -from smmap.mman import WindowCursor +from smmap.mman import ( + WindowCursor, + SlidingWindowMapManager, + StaticWindowMapManager + ) from smmap.util import align_to_mmap -from smmap.exc import RegionCollectionError from random import randint from time import time @@ -67,7 +69,7 @@ class TestMMan(TestBase): # doesn't raise if we are within the limit man._collect_lru_region(10) - # doesn't fail if we overallocate + # doesn't fail if we over-allocate assert man._collect_lru_region(sys.maxsize) == 0 # use a region, verify most basic functionality diff --git a/smmap/test/test_util.py b/smmap/test/test_util.py index 8afba00..745da83 100644 --- a/smmap/test/test_util.py +++ b/smmap/test/test_util.py @@ -1,6 +1,13 @@ from .lib import TestBase, FileCreator -from smmap.util import * +from smmap.util import ( + MapWindow, + MapRegion, + MapRegionList, + ALLOCATIONGRANULARITY, + is_64_bit, + align_to_mmap + ) import os import sys diff --git a/smmap/util.py b/smmap/util.py index 3396d90..a4d7d8f 100644 --- a/smmap/util.py +++ b/smmap/util.py @@ -113,7 +113,7 @@ class MapRegion(object): '__weakref__' ] _need_compat_layer = sys.version_info[0] < 3 and sys.version_info[1] < 6 - + if _need_compat_layer: __slots__.append('_mfb') # mapped memory buffer to provide offset #END handle additional slot @@ -283,4 +283,4 @@ class MapRegionList(list): #END update file size return self._file_size -#} END utilty classes +#} END utility classes |
