Skip to content

Commit 403ad78

Browse files
committed
Delay importing sys.getrefcount until needed
This makes it possibly to at least install on PyPy Addresses: GH-4 ("pypy compatibility")
1 parent f068010 commit 403ad78

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

smmap/mman.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from weakref import ref
1212
import sys
13-
from sys import getrefcount
1413
from functools import reduce
1514

1615
__all__ = ["StaticWindowMapManager", "SlidingWindowMapManager", "WindowCursor"]

smmap/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
from mmap import PAGESIZE as ALLOCATIONGRANULARITY
1313
#END handle pythons missing quality assurance
1414

15-
from sys import getrefcount
16-
1715
__all__ = [ "align_to_mmap", "is_64_bit",
1816
"MapWindow", "MapRegion", "MapRegionList", "ALLOCATIONGRANULARITY"]
1917

@@ -210,6 +208,7 @@ def includes_ofs(self, ofs):
210208

211209
def client_count(self):
212210
""":return: number of clients currently using this region"""
211+
from sys import getrefcount
213212
# -1: self on stack, -1 self in this method, -1 self in getrefcount
214213
return getrefcount(self)-3
215214

@@ -256,6 +255,7 @@ def __init__(self, path_or_fd):
256255

257256
def client_count(self):
258257
""":return: amount of clients which hold a reference to this instance"""
258+
from sys import getrefcount
259259
return getrefcount(self)-3
260260

261261
def path_or_fd(self):

0 commit comments

Comments
 (0)