Improve representation of Constants
[linpy.git] / pypol / isl.py
index 5a20514..f15cea1 100644 (file)
@@ -1,14 +1,4 @@
-"""
-note: for islpy
-isl format: basic set: ("{[x, y] : x >= 0 and x < 5 and y >= 0 and y < x+4 }")
-"""
-
 import ctypes, ctypes.util
-import functools
-import math
-import numbers
-import operator
-import re
 
 from . import _isl
 
@@ -21,7 +11,9 @@ libisl.isl_dim_set = _isl.isl_dim_set
 
 class IslObject:
 
-    __slots__ = ('_ptr')
+    __slots__ = (
+        '_ptr',
+    )
 
     def __init__(self, ptr):
         self._ptr = ptr
@@ -34,7 +26,8 @@ class IslObject:
 class Context(IslObject):
 
     def __init__(self):
-        self._ptr = libisl.isl_ctx_alloc()
+        ptr = libisl.isl_ctx_alloc()
+        super().__init__(ptr)
 
     #comment out so does not delete itself after being created
     #def __del__(self):
@@ -53,6 +46,8 @@ class BasicSet(IslObject):
         ctx = libisl.isl_local_space_get_ctx(ls)
         p = libisl.isl_printer_to_str(ctx)
         p = libisl.isl_printer_print_basic_set(p, self)
-        string = libisl.isl_printer_get_str(p)
-        string = str(string.decode())
+        string = libisl.isl_printer_get_str(p).decode()
         return string
+
+    def __del__(self):
+        libisl.isl_basic_set_free(self)