From: DylanYoung (@DylanYoung) <noreply+DylanYoung@github.com>
To: psycopg/psycopg <noreply+psycopg-psycopg@github.com>
Subject: Re: [psycopg/psycopg] PR #1324: Faster C Load Sequence
Date: Sun, 14 Jun 2026 01:53:28 +0000
Message-ID: <gh-psycopg-psycopg-1324-rc3408879563@github.com> (raw)
In-Reply-To: <gh-psycopg-psycopg-1324-rc3408603272@github.com>
References: <gh-psycopg-psycopg-1324@github.com>
<gh-psycopg-psycopg-1324-rc3408603272@github.com>
(on psycopg_c/psycopg_c/_psycopg/copy.pyx)
`sclen` is initialized to zero, so on the first pass, this will always allocate memory, then it only allocates more memory if the next string is larger than the largest string seen so far. `scratch` is initialized as `NULL` so that the first allocation is a malloc, rather than a realloc.