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-Tag: 3.2.7~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0bc7a16c4f056b6ceeb69fde1cd44fcb27d8c52;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 a2bf8c146..1c0f747da 100644 --- a/psycopg/psycopg/types/composite.py +++ b/psycopg/psycopg/types/composite.py @@ -219,14 +219,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: @@ -235,7 +237,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):