From: Daniele Varrazzo Date: Wed, 26 Mar 2025 18:56:32 +0000 (+0100) Subject: perf(composite): drop an if and a tuple() call X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=99ff2364b3fba759399eef79a6262e2789a548ec;p=thirdparty%2Fpsycopg.git perf(composite): drop an if and a tuple() call --- diff --git a/psycopg/psycopg/types/composite.py b/psycopg/psycopg/types/composite.py index fa46393fb..b29279562 100644 --- a/psycopg/psycopg/types/composite.py +++ b/psycopg/psycopg/types/composite.py @@ -220,14 +220,16 @@ class RecordBinaryLoader(Loader): nfields = unpack_len(data, 0)[0] offset = 4 oids = [] - record = [] + record: list[Buffer | None] = [] for _ in range(nfields): oid, length = _unpack_oidlen(data, offset) offset += 8 - record.append(data[offset : offset + length] if length != -1 else None) oids.append(oid) if length >= 0: + record.append(data[offset : offset + length]) offset += length + else: + record.append(None) key = tuple(oids) try: @@ -236,7 +238,7 @@ class RecordBinaryLoader(Loader): tx = self._txs[key] = Transformer(self._ctx) tx.set_loader_types(oids, self.format) - return tx.load_sequence(tuple(record)) + return tx.load_sequence(record) class CompositeLoader(RecordLoader):