summaryrefslogtreecommitdiff
path: root/smmap
diff options
context:
space:
mode:
authorMarc Abramowitz <marc@marc-abramowitz.com>2014-06-13 22:24:23 -0700
committerMarc Abramowitz <marc@marc-abramowitz.com>2014-06-13 22:24:23 -0700
commit403ad7816e2c88be78606cfee2d9944f535e7ed7 (patch)
tree3d7482fc06bbd6dcffb49bef9c0b1077f85343e0 /smmap
parentf0680101739da3435bbae0139765bb5ce65bcb92 (diff)
downloadsmmap-403ad7816e2c88be78606cfee2d9944f535e7ed7.tar.gz
Delay importing sys.getrefcount until needed
This makes it possibly to at least install on PyPy Addresses: GH-4 ("pypy compatibility")
Diffstat (limited to 'smmap')
-rw-r--r--smmap/mman.py1
-rw-r--r--smmap/util.py4
2 files changed, 2 insertions, 3 deletions
diff --git a/smmap/mman.py b/smmap/mman.py
index 9cc251f..637a284 100644
--- a/smmap/mman.py
+++ b/smmap/mman.py
@@ -10,7 +10,6 @@ from .util import (
from weakref import ref
import sys
-from sys import getrefcount
from functools import reduce
__all__ = ["StaticWindowMapManager", "SlidingWindowMapManager", "WindowCursor"]
diff --git a/smmap/util.py b/smmap/util.py
index f4ecd22..ec86cbf 100644
--- a/smmap/util.py
+++ b/smmap/util.py
@@ -12,8 +12,6 @@ except ImportError:
from mmap import PAGESIZE as ALLOCATIONGRANULARITY
#END handle pythons missing quality assurance
-from sys import getrefcount
-
__all__ = [ "align_to_mmap", "is_64_bit",
"MapWindow", "MapRegion", "MapRegionList", "ALLOCATIONGRANULARITY"]
@@ -210,6 +208,7 @@ class MapRegion(object):
def client_count(self):
""":return: number of clients currently using this region"""
+ from sys import getrefcount
# -1: self on stack, -1 self in this method, -1 self in getrefcount
return getrefcount(self)-3
@@ -256,6 +255,7 @@ class MapRegionList(list):
def client_count(self):
""":return: amount of clients which hold a reference to this instance"""
+ from sys import getrefcount
return getrefcount(self)-3
def path_or_fd(self):