From: Arturas Moskvinas Date: Fri, 7 Aug 2015 16:17:31 +0000 (+0300) Subject: Improve odict performance by making key search O(1) X-Git-Tag: dev-2a51c9b95d06~31^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6822b7fa7d12be1db8433a157345045dadebe5eb;p=thirdparty%2Fbabel.git Improve odict performance by making key search O(1) --- diff --git a/babel/util.py b/babel/util.py index a65fce36..8d88fc53 100644 --- a/babel/util.py +++ b/babel/util.py @@ -172,8 +172,9 @@ class odict(dict): self._keys.remove(key) def __setitem__(self, key, item): + new_key = key not in self dict.__setitem__(self, key, item) - if key not in self._keys: + if new_key: self._keys.append(key) def __iter__(self):