Author: Carl Friedrich Bolz-Tereick <[email protected]>
Branch:
Changeset: r97786:292b84d69855
Date: 2019-10-16 14:03 +0200
http://bitbucket.org/pypy/pypy/changeset/292b84d69855/
Log: small improvement: if the map can't be promoted (eg when using
setattr), check first whether the attribute goes into the first five
slots, or into the extension array
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -692,10 +692,12 @@
return unerase_item(erased)
def _mapdict_write_storage(self, storageindex, value):
- for i in rangenmin1:
- if storageindex == i:
- setattr(self, "_value%s" % i, value)
- return
+ assert storageindex >= 0
+ if storageindex < nmin1:
+ for i in rangenmin1:
+ if storageindex == i:
+ setattr(self, "_value%s" % i, value)
+ return
if self._has_storage_list():
self._mapdict_get_storage_list()[storageindex - nmin1] = value
return
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit