Author: Armin Rigo <[email protected]>
Branch: rpython-hash
Changeset: r89823:6879b32267d1
Date: 2017-01-28 17:45 +0100
http://bitbucket.org/pypy/pypy/changeset/6879b32267d1/
Log: Cleanups and comments
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -287,7 +287,7 @@
for ek, ev in items:
result.dictdef.generalize_key(self.immutablevalue(ek))
result.dictdef.generalize_value(self.immutablevalue(ev))
- result.dictdef.seen_prebuilt_key(ek)
+ #dictdef.seen_prebuilt_key(ek)---not needed any more
seen_elements = len(items)
# if the dictionary grew during the iteration,
# start over again
diff --git a/rpython/annotator/dictdef.py b/rpython/annotator/dictdef.py
--- a/rpython/annotator/dictdef.py
+++ b/rpython/annotator/dictdef.py
@@ -115,13 +115,5 @@
def generalize_value(self, s_value):
self.dictvalue.generalize(s_value)
- def seen_prebuilt_key(self, x):
- # In case we are an r_dict, we don't ask for the hash ourselves.
- # Note that if the custom hashing function ends up asking for
- # the hash of x, then it must use compute_hash() itself, so it
- # works out.
- if not self.dictkey.custom_eq_hash:
- compute_hash(x)
-
def __repr__(self):
return '<{%r: %r}>' % (self.dictkey.s_value, self.dictvalue.s_value)
diff --git a/rpython/memory/gctransform/framework.py
b/rpython/memory/gctransform/framework.py
--- a/rpython/memory/gctransform/framework.py
+++ b/rpython/memory/gctransform/framework.py
@@ -610,11 +610,6 @@
def special_funcptr_for_type(self, TYPE):
return self.layoutbuilder.special_funcptr_for_type(TYPE)
- def get_hash_offset(self, T):
- type_id = self.get_type_id(T)
- assert not self.gcdata.q_is_varsize(type_id)
- return self.gcdata.q_fixed_size(type_id)
-
def finish_tables(self):
group = self.layoutbuilder.close_table()
log.info("assigned %s typeids" % (len(group.members), ))
diff --git a/rpython/rlib/objectmodel.py b/rpython/rlib/objectmodel.py
--- a/rpython/rlib/objectmodel.py
+++ b/rpython/rlib/objectmodel.py
@@ -465,8 +465,14 @@
Note that this can return 0 or -1 too.
- It returns the same number, both before and after translation.
- Dictionaries don't need to be rehashed after translation.
+ NOTE: It returns a different number before and after translation!
+ Dictionaries will be rehashed when the translated program starts.
+ Be careful about other places that store or depend on a hash value:
+ if such a place can exist before translation, you should add for
+ example a _cleanup_() method to clear this cache during translation.
+
+ (Nowadays we could completely remove compute_hash() and decide that
+ hash(x) is valid RPython instead, at least for the types listed here.)
"""
if isinstance(x, (str, unicode)):
return _hash_string(x)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit