From a3c10d31c77aece45da31748badbf26516d09cca Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Wed, 14 Sep 2011 17:17:54 +0200 Subject: [PATCH] http.client: Reduce performance impact by assertion Call dict.values once instead of N times. Signed-off-by: Michael Hanselmann Reviewed-by: Iustin Pop --- lib/http/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/http/client.py b/lib/http/client.py index 84cd0b7..1e02e4c 100644 --- a/lib/http/client.py +++ b/lib/http/client.py @@ -352,10 +352,11 @@ class HttpClientPool: """Returns HTTP clients to the pool. """ + assert not frozenset(pclients) & frozenset(self._pool.values()) + for pc in pclients: self._logger.debug("Returning client %s to pool", pc) assert pc.identity not in self._pool - assert pc not in self._pool.values() self._pool[pc.identity] = pc # Check for unused clients -- 1.7.10.4