From: Daniele Varrazzo Date: Mon, 15 Aug 2022 00:50:50 +0000 (+0200) Subject: perf(psycopg_c): avoid to create a tuple in fetch_many() loop X-Git-Tag: 3.1~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=657d3ff2b7c9d3ed61e97185758ab36aa3056650;p=thirdparty%2Fpsycopg.git perf(psycopg_c): avoid to create a tuple in fetch_many() loop --- diff --git a/psycopg_c/psycopg_c/_psycopg/generators.pyx b/psycopg_c/psycopg_c/_psycopg/generators.pyx index f244f24bc..e0a9a765a 100644 --- a/psycopg_c/psycopg_c/_psycopg/generators.pyx +++ b/psycopg_c/psycopg_c/_psycopg/generators.pyx @@ -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