[Python-3000-checkins] r51406 - in python/branches/p3yk/Lib: compiler/misc.py compiler/pyassem.py compiler/symbols.py compiler/transformer.py compiler/visitor.py email/_parseaddr.py email/message.py

guido.van.rossum python-3000-checkins at python.org
Sat Aug 19 17:28:38 CEST 2006


Author: guido.van.rossum
Date: Sat Aug 19 17:28:37 2006
New Revision: 51406

Modified:
   python/branches/p3yk/Lib/compiler/misc.py
   python/branches/p3yk/Lib/compiler/pyassem.py
   python/branches/p3yk/Lib/compiler/symbols.py
   python/branches/p3yk/Lib/compiler/transformer.py
   python/branches/p3yk/Lib/compiler/visitor.py
   python/branches/p3yk/Lib/email/_parseaddr.py
   python/branches/p3yk/Lib/email/message.py
Log:
Stomp out more hsa_key() calls.


Modified: python/branches/p3yk/Lib/compiler/misc.py
==============================================================================
--- python/branches/p3yk/Lib/compiler/misc.py	(original)
+++ python/branches/p3yk/Lib/compiler/misc.py	Sat Aug 19 17:28:37 2006
@@ -14,13 +14,13 @@
     def __len__(self):
         return len(self.elts)
     def __contains__(self, elt):
-        return self.elts.has_key(elt)
+        return elt in self.elts
     def add(self, elt):
         self.elts[elt] = elt
     def elements(self):
         return self.elts.keys()
     def has_elt(self, elt):
-        return self.elts.has_key(elt)
+        return elt in self.elts
     def remove(self, elt):
         del self.elts[elt]
     def copy(self):

Modified: python/branches/p3yk/Lib/compiler/pyassem.py
==============================================================================
--- python/branches/p3yk/Lib/compiler/pyassem.py	(original)
+++ python/branches/p3yk/Lib/compiler/pyassem.py	Sat Aug 19 17:28:37 2006
@@ -210,7 +210,7 @@
     order = []
     seen[b] = b
     for c in b.get_children():
-        if seen.has_key(c):
+        if c in seen:
             continue
         order = order + dfs_postorder(c, seen)
     order.append(b)
@@ -406,7 +406,7 @@
         seen = {}
 
         def max_depth(b, d):
-            if seen.has_key(b):
+            if b in seen:
                 return d
             seen[b] = 1
             d = d + depth[b]
@@ -482,7 +482,7 @@
         for name in self.cellvars:
             cells[name] = 1
         self.cellvars = [name for name in self.varnames
-                         if cells.has_key(name)]
+                         if name in cells]
         for name in self.cellvars:
             del cells[name]
         self.cellvars = self.cellvars + cells.keys()

Modified: python/branches/p3yk/Lib/compiler/symbols.py
==============================================================================
--- python/branches/p3yk/Lib/compiler/symbols.py	(original)
+++ python/branches/p3yk/Lib/compiler/symbols.py	Sat Aug 19 17:28:37 2006
@@ -49,9 +49,9 @@
 
     def add_global(self, name):
         name = self.mangle(name)
-        if self.uses.has_key(name) or self.defs.has_key(name):
+        if name in self.uses or name in self.defs:
             pass # XXX warn about global following def/use
-        if self.params.has_key(name):
+        if name in self.params:
             raise SyntaxError, "%s in %s is global and parameter" % \
                   (name, self.name)
         self.globals[name] = 1
@@ -88,14 +88,14 @@
 
         The scope of a name could be LOCAL, GLOBAL, FREE, or CELL.
         """
-        if self.globals.has_key(name):
+        if name in self.globals:
             return SC_GLOBAL
-        if self.cells.has_key(name):
+        if name in self.cells:
             return SC_CELL
-        if self.defs.has_key(name):
+        if name in self.defs:
             return SC_LOCAL
-        if self.nested and (self.frees.has_key(name) or
-                            self.uses.has_key(name)):
+        if self.nested and (name in self.frees or
+                            name in self.uses):
             return SC_FREE
         if self.nested:
             return SC_UNKNOWN
@@ -108,8 +108,8 @@
         free = {}
         free.update(self.frees)
         for name in self.uses.keys():
-            if not (self.defs.has_key(name) or
-                    self.globals.has_key(name)):
+            if not (name in self.defs or
+                    name in self.globals):
                 free[name] = 1
         return free.keys()
 
@@ -134,7 +134,7 @@
         free.
         """
         self.globals[name] = 1
-        if self.frees.has_key(name):
+        if name in self.frees:
             del self.frees[name]
         for child in self.children:
             if child.check_name(name) == SC_FREE:

Modified: python/branches/p3yk/Lib/compiler/transformer.py
==============================================================================
--- python/branches/p3yk/Lib/compiler/transformer.py	(original)
+++ python/branches/p3yk/Lib/compiler/transformer.py	Sat Aug 19 17:28:37 2006
@@ -82,7 +82,7 @@
 
 def Node(*args):
     kind = args[0]
-    if nodes.has_key(kind):
+    if kind in nodes:
         try:
             return nodes[kind](*args[1:])
         except TypeError:

Modified: python/branches/p3yk/Lib/compiler/visitor.py
==============================================================================
--- python/branches/p3yk/Lib/compiler/visitor.py	(original)
+++ python/branches/p3yk/Lib/compiler/visitor.py	Sat Aug 19 17:28:37 2006
@@ -84,7 +84,7 @@
             meth(node, *args)
         elif self.VERBOSE > 0:
             klass = node.__class__
-            if not self.examples.has_key(klass):
+            if klass not in self.examples:
                 self.examples[klass] = klass
                 print
                 print self.visitor

Modified: python/branches/p3yk/Lib/email/_parseaddr.py
==============================================================================
--- python/branches/p3yk/Lib/email/_parseaddr.py	(original)
+++ python/branches/p3yk/Lib/email/_parseaddr.py	Sat Aug 19 17:28:37 2006
@@ -109,7 +109,7 @@
         return None
     tzoffset = None
     tz = tz.upper()
-    if _timezones.has_key(tz):
+    if tz in _timezones:
         tzoffset = _timezones[tz]
     else:
         try:

Modified: python/branches/p3yk/Lib/email/message.py
==============================================================================
--- python/branches/p3yk/Lib/email/message.py	(original)
+++ python/branches/p3yk/Lib/email/message.py	Sat Aug 19 17:28:37 2006
@@ -245,16 +245,16 @@
         # BAW: should we accept strings that can serve as arguments to the
         # Charset constructor?
         self._charset = charset
-        if not self.has_key('MIME-Version'):
+        if 'MIME-Version' not in self:
             self.add_header('MIME-Version', '1.0')
-        if not self.has_key('Content-Type'):
+        if 'Content-Type' not in self:
             self.add_header('Content-Type', 'text/plain',
                             charset=charset.get_output_charset())
         else:
             self.set_param('charset', charset.get_output_charset())
         if str(charset) <> charset.get_output_charset():
             self._payload = charset.body_encode(self._payload)
-        if not self.has_key('Content-Transfer-Encoding'):
+        if 'Content-Transfer-Encoding' not in self:
             cte = charset.get_body_encoding()
             try:
                 cte(self)
@@ -547,7 +547,7 @@
         VALUE item in the 3-tuple) is always unquoted, unless unquote is set
         to False.
         """
-        if not self.has_key(header):
+        if header not in self:
             return failobj
         for k, v in self._get_params_preserve(failobj, header):
             if k.lower() == param.lower():
@@ -578,7 +578,7 @@
         if not isinstance(value, tuple) and charset:
             value = (charset, language, value)
 
-        if not self.has_key(header) and header.lower() == 'content-type':
+        if header not in self and header.lower() == 'content-type':
             ctype = 'text/plain'
         else:
             ctype = self.get(header)
@@ -613,7 +613,7 @@
         False.  Optional header specifies an alternative to the Content-Type
         header.
         """
-        if not self.has_key(header):
+        if header not in self:
             return
         new_ctype = ''
         for p, v in self.get_params(header=header, unquote=requote):
@@ -649,7 +649,7 @@
         if header.lower() == 'content-type':
             del self['mime-version']
             self['MIME-Version'] = '1.0'
-        if not self.has_key(header):
+        if header not in self:
             self[header] = type
             return
         params = self.get_params(header=header, unquote=requote)


More information about the Python-3000-checkins mailing list