#14 Drop calls to .keys()
Merged 8 years ago by puiterwijk. Opened 8 years ago by pingou.
pingou/ipsilon small_optimization  into  master

@@ -281,7 +281,7 @@ 

              if g in globals():

                  globals()[g] = val

              else:

-                 for k in globals().keys():

+                 for k in globals():

                      if k.lower() == g.lower():

                          globals()[k] = val

                          break

@@ -313,7 +313,7 @@ 

              if g in globals():

                  globals()[g] = val

              else:

-                 for k in globals().keys():

+                 for k in globals():

                      if k.lower() == g.lower():

                          globals()[k] = val

                          break

@@ -70,7 +70,7 @@ 

          else:

              data = idp.get_data()

  

-         for idval in data.keys():

+         for idval in data:

              result = dict(provider=data[idval].get('name'),

                            metadata=data[idval].get('metadata'),)

              results.append(result)

file modified
+1 -1
@@ -23,7 +23,7 @@ 

  

      @classmethod

      def get_connection(cls, name):

-         if name not in cls.__instances.keys():

+         if name not in cls.__instances:

              if cherrypy.config.get('db.conn.log', False):

                  logging.debug('SqlStore new: %s', name)

              cls.__instances[name] = SqlStore(name)

file modified
+1 -1
@@ -77,7 +77,7 @@ 

          # If ignore_case is True,

          # then PD translates case insensitively prefixes

          PD = dict()

-         for k in attributes.keys():

+         for k in attributes:

              if ignore_case:

                  # note duplicates that differ only by case

                  # will be lost here, beware!

file modified
+2 -2
@@ -101,10 +101,10 @@ 

                           nameid='unspecified'):

          newconf = ConfigParser.ConfigParser()

          newconf.add_section('globals')

-         for k in global_opts.keys():

+         for k in global_opts:

              newconf.set('globals', k, global_opts[k])

          newconf.add_section('arguments')

-         for k in args_opts.keys():

+         for k in args_opts:

              newconf.set('arguments', k, args_opts[k])

  

          profile = io.BytesIO()

file modified
+1 -1
@@ -85,7 +85,7 @@ 

      data.pop('MELLON_IDP')

      data.pop('MELLON_NAME_ID')

  

-     for key in expected.keys():

+     for key in expected:

          item = data.pop('MELLON_' + key)

          if item != expected[key]:

              raise ValueError('Expected %s, got %s' % (expected[key], item))

file modified
+1 -1
@@ -55,7 +55,7 @@ 

      splist = []

      spport = 45081

  

-     for nameid in SAML2_NAMEID_MAP.keys():

+     for nameid in SAML2_NAMEID_MAP:

          nameid = nameid

          spdata = {'nameid': nameid, 'addr': '127.0.0.11', 'port': str(spport)}

          splist.append(spdata)

no initial comment

Please add an explanation in the git commit body as to why we want to do this.

This is detailed at: http://blog.pingoured.fr/index.php?post/2012/03/12/Python-notes-to-self .

Though I do agree having a short summary in the commit body would be nice.

I do not disagree with the patch, I just want a comment that explains why you want to do it. doesn't need to be long and can have a URL in it that points to further reading.

Commit message adjusted, thanks!