diff options
| author | Pierre-Yves Chibon <pingou@pingoured.fr> | 2015-07-28 11:19:49 +0000 |
|---|---|---|
| committer | Patrick Uiterwijk <puiterwijk@redhat.com> | 2015-08-11 12:08:50 +0200 |
| commit | ce2bbec3f2a010cfa26363a91a6224efe484f06f (patch) | |
| tree | 0195f3654105f7a1e6b72743322c024c4717718b /ipsilon/util | |
| parent | db9da225bce11ddeef1b5a2d511f18e17a808f15 (diff) | |
| download | ipsilon-ce2bbec3f2a010cfa26363a91a6224efe484f06f.tar.gz ipsilon-ce2bbec3f2a010cfa26363a91a6224efe484f06f.tar.xz ipsilon-ce2bbec3f2a010cfa26363a91a6224efe484f06f.zip | |
Drop all the calls to .keys() when iterating on the keys of a dict
When browsing the keys of a dictionary, you can use the ``.keys()`` method but
that is in fact only really useful if you want to store the list of keys first
and act on them (like sorting them or so).
If you just want to iterate through all the keys, no matter the order, then it
is much much faster to just do: ``for key in dict``
Some stats about this can be found there:
http://blog.pingoured.fr/index.php?post/2012/03/12/Python-notes-to-self
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Reviewed-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'ipsilon/util')
| -rw-r--r-- | ipsilon/util/data.py | 2 | ||||
| -rw-r--r-- | ipsilon/util/policy.py | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/ipsilon/util/data.py b/ipsilon/util/data.py index e0cd6e1..3c116bb 100644 --- a/ipsilon/util/data.py +++ b/ipsilon/util/data.py @@ -23,7 +23,7 @@ class SqlStore(Log): @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) diff --git a/ipsilon/util/policy.py b/ipsilon/util/policy.py index 8f70673..f1915cc 100644 --- a/ipsilon/util/policy.py +++ b/ipsilon/util/policy.py @@ -77,7 +77,7 @@ class Policy(Log): # 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! |
