Open itamarst opened 6 years ago
Enforce 0.3.4.
import sys from typing import List import enforce @enforce.runtime_validation def noop_validated(i: List) -> List: return i def noop(i: List) -> List: return i if __name__ == '__main__': mylist = [] print("Initial refcounts", sys.getrefcount(mylist)) noop(mylist) print("Refcounts after noop():", sys.getrefcount(mylist)) noop_validated(mylist) print("Refcounts after noop_validated():", sys.getrefcount(mylist))
Results:
$ python /tmp/reproducer.py Initial refcounts 2 Refcounts after noop(): 2 Refcounts after noop_validated(): 6
Enforce 0.3.4.
Results: