[pypy-svn] r25485 - pypy/dist/pypy/objspace/constraint
auc at codespeak.net
auc at codespeak.net
Fri Apr 7 11:54:49 CEST 2006
Author: auc
Date: Fri Apr 7 11:54:46 2006
New Revision: 25485
Modified:
pypy/dist/pypy/objspace/constraint/domain.py
Log:
Modified: pypy/dist/pypy/objspace/constraint/domain.py
==============================================================================
--- pypy/dist/pypy/objspace/constraint/domain.py (original)
+++ pypy/dist/pypy/objspace/constraint/domain.py Fri Apr 7 11:54:46 2006
@@ -54,36 +54,36 @@
This class uses a dictionnary to make sure that there are
no duplicate values"""
W_AbstractDomain.__init__(self, space)
- self._values = {}
+ self._values = space.newdict([])
self.set_values(w_values)
def set_values(self, w_values):
for w_v in w_values.wrappeditems:
- self._values[w_v] = True
+ self._values.content[w_v] = self._space.w_True
def w_remove_value(self, w_value):
"""Remove value of domain and check for consistency"""
- self._values.pop(w_value)
+ del self._values.content[w_value]
self._value_removed()
def w_remove_values(self, w_values):
"""Remove values of domain and check for consistency"""
if self._space.is_true(self._space.gt(self._space.len(w_values),
self._space.newint(0))) :
- for val in w_values.wrappeditems :
- self._values.pop(val)
+ for w_val in w_values.wrappeditems :
+ del self._values.content [w_val]
self._value_removed()
__delitem__ = w_remove_value
def w_size(self):
"""computes the size of a finite domain"""
- return self._space.newint(len(self._values))
+ return self._space.newint(len(self._values.content))
__len__ = w_size
def w_get_values(self):
"""return all the values in the domain
in an indexable sequence"""
- return self._space.newlist([x for x in self._values])
+ return self._space.newlist([x for x in self._values.content])
def __iter__(self):
return iter(self._values)
@@ -97,8 +97,9 @@
def __eq__(self, w_other):
if not isinstance(w_other, W_FiniteDomain):
- return self._space.w_False
- return self._space.newbool(self._space.eq_w(self._values, w_other._values))
+ return self._space.newbool(False)
+ return self._space.eq(self._values, w_other._values)
+
def __ne__(self, w_other):
return not self == w_other
@@ -117,7 +118,7 @@
def intersection__FiniteDomain_FiniteDomain(space, w_fd1, w_fd2):
- w_v1 = w_fd1._values
+ w_v1 = w_fd1._values.content
w_res = [w_v for w_v in w_fd2.w_get_values().wrappeditems
if w_v in w_v1]
return make_fd(space, space.newlist(w_res))
More information about the Pypy-commit
mailing list