Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l9FAt-0001Us-31 for psycopg@arkaria.postgresql.org; Mon, 08 Feb 2021 22:38:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l9FAp-0007Q6-HU for psycopg@arkaria.postgresql.org; Mon, 08 Feb 2021 22:38:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l9FAp-0007Py-C0 for psycopg@lists.postgresql.org; Mon, 08 Feb 2021 22:38:27 +0000 Received: from mail-il1-f182.google.com ([209.85.166.182]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l9FAm-0000FH-Qq for psycopg@postgresql.org; Mon, 08 Feb 2021 22:38:26 +0000 Received: by mail-il1-f182.google.com with SMTP id y5so14360965ilg.4 for ; Mon, 08 Feb 2021 14:38:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DdgBRySDiMmdVPAveGBK6H3is2INOAKYnkUF6SU7M4Y=; b=YYZa4vUYCyT/vBj/ttpSHtLAcFhYZAvIvKMzCl6UDkXjflZTw4tOYUWmEIklKHl8I+ f6i1UjSlniJEClt127RVJerVzEzxTUSMcjmbWSQTxL9W1rRk/0/m/dDF4922fmVNAeD8 GN0BR+N84Z4/kEw0/IOKFtfkFPbNi851aIyUBTYytng32UoMfWUVGqqcI4QJrY/eOOp0 Ry7cCl9jDZwCU/piSbR3Zy/LqvTCauFIEnM+y7vQCQwLTa/KIj3kdksfs/LA3G4rVKf8 L2RsMwkhdtkkC4YE7+UxtFHgg0lbm5nFek5cC+TKQXf92Rf1U9CeiBiSk5Ybo2Io4v4a HWnA== X-Gm-Message-State: AOAM530BldNlNsaAhAf0eA4UcUOB2c0gf5gGPTzD8PlvrdpTbqCiNNGV mwpSBgkXHHi8oqLvYAb50R8N/GSPr8nE2B9stvo= X-Google-Smtp-Source: ABdhPJzYvsdsMA9KmwiVpiv9Nv+tByzgkJo+UKtk0ZxZawUmi2yVGZnEFN+OTd9ZX4ebd/z8nKQe/SDOgHE/3V1fRvM= X-Received: by 2002:a05:6e02:1b84:: with SMTP id h4mr17011715ili.196.1612823902572; Mon, 08 Feb 2021 14:38:22 -0800 (PST) MIME-Version: 1.0 References: <4eb4e86a-c813-bb8f-ae93-4f1b9fd46b6b@dalibo.com> In-Reply-To: From: Daniel Fortunov Date: Mon, 8 Feb 2021 22:38:10 +0000 Message-ID: Subject: Re: Latest developments in psycopg3 To: Denis Laxalde Cc: Daniele Varrazzo , psycopg@postgresql.org Content-Type: multipart/alternative; boundary="000000000000cc580e05badad30d" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000cc580e05badad30d Content-Type: text/plain; charset="UTF-8" > > > 1) We can provide a feature to select the type of cursor that is not > > much dissimilar from psycopg2 > > 2) Do we need DictCursor/RealDictCursor? ISTM that one of the two > > would be sufficient? Possibly an object inheriting from a Python dict > > instead of emulating it so that e.g. json.dumps() > > Inheriting from dict is strange because we only need read access. So > rather collections.abc.Mapping, I think. > One advantage of using a real dict is that it leaves the door open for the caller to mutate the results as they consume them. A little impure, I know, but one practical example I can think of would be where you want to augment your results with additional data (coming from a different source, outside the database). RealDictCursor gives you the flexibility to do this, whereas collections.abc.Mapping would force you to construct a new dict instance for every row in order to get the same result. --000000000000cc580e05badad30d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> 1) We can provide a feature to select the type of c= ursor that is not
> much dissimilar from psycopg2
> 2) Do we need DictCursor/RealDictCursor? ISTM that one of the two
> would be sufficient? Possibly an object inheriting from a Python dict<= br> > instead of emulating it so that e.g. json.dumps()

Inheriting from dict is strange because we only need read access. So
rather collections.abc.Mapping, I think.
=C2=A0
<= div>One advantage of using a real dict is that it leaves the door open for = the caller to mutate the results as they consume them. A little impure, I k= now, but one practical example I can think of would be where you want to au= gment your results with additional data (coming from a different source, ou= tside the database).

RealDictCursor gives you the = flexibility to do this, whereas collections.abc.Mapping would force you to = construct a new dict instance for every row in order to get the same result= .
--000000000000cc580e05badad30d--