]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
perf(psycopg_c): avoid to create a tuple in fetch_many() loop
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 15 Aug 2022 00:50:50 +0000 (02:50 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 15 Aug 2022 13:41:04 +0000 (15:41 +0200)
psycopg_c/psycopg_c/_psycopg/generators.pyx

index f244f24bc7b8749a65e79134acc6317e6e58a190..e0a9a765a54c953ef49063b363dae75594d71750 100644 (file)
@@ -130,7 +130,11 @@ def fetch_many(pq.PGconn pgconn) -> PQGen[List[PGresult]]:
         pgres = result._pgresult_ptr
 
         status = libpq.PQresultStatus(pgres)
-        if status in (libpq.PGRES_COPY_IN, libpq.PGRES_COPY_OUT, libpq.PGRES_COPY_BOTH):
+        if (
+            status == libpq.PGRES_COPY_IN
+            or status == libpq.PGRES_COPY_OUT
+            or status == libpq.PGRES_COPY_BOTH
+        ):
             # After entering copy mode the libpq will create a phony result
             # for every request so let's break the endless loop.
             break