Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Thank heaven for startups; without them we'd never have any advances." -- Seymour Cray


devel / comp.lang.python / RE: To clarify how Python handles two equal objects

SubjectAuthor
* Re: To clarify how Python handles two equal objectsJen Kris
`* Re: To clarify how Python handles two equal objectsGreg Ewing
 +- Re: To clarify how Python handles two equal objectsJen Kris
 +- Re: To clarify how Python handles two equal objectsRoel Schroeven
 +* Re: To clarify how Python handles two equal objectsJen Kris
 |`* Re: To clarify how Python handles two equal objectsStefan Ram
 | `- Re: To clarify how Python handles two equal objectsPeter J. Holzer
 +- Re: To clarify how Python handles two equal objectsRichard Damon
 +* RE: To clarify how Python handles two equal objects<avi.e.gross
 |`* Re: To clarify how Python handles two equal objectsAxel Reichert
 | +- Re: To clarify how Python handles two equal objectsStefan Ram
 | `- RE: To clarify how Python handles two equal objects<avi.e.gross
 +- RE: To clarify how Python handles two equal objectsJen Kris
 +* Re: To clarify how Python handles two equal objectsBob van der Poel
 |`- Re: To clarify how Python handles two equal objectsStefan Ram
 +- Re: To clarify how Python handles two equal objectsJen Kris
 +- Re: To clarify how Python handles two equal objectsPeter J. Holzer
 +- RE: To clarify how Python handles two equal objects<avi.e.gross
 +- RE: To clarify how Python handles two equal objects<avi.e.gross
 +* RE: To clarify how Python handles two equal objectsJen Kris
 |`- Re: To clarify how Python handles two equal objectsMark Bourne
 +- Re: To clarify how Python handles two equal objectsChris Angelico
 +- Re: To clarify how Python handles two equal objectsJen Kris
 +- Re: To clarify how Python handles two equal objectsChris Angelico
 +- Re: To clarify how Python handles two equal objectsRoel Schroeven
 +- Re: To clarify how Python handles two equal objectsFrank Millman
 `- RE: To clarify how Python handles two equal objects<avi.e.gross

Pages:12
Re: To clarify how Python handles two equal objects

<tq0u8b$179f$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=25555&group=comp.lang.python#25555

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!Bz6wgdG13kDEF+8WFnpMfQ.user.46.165.242.75.POSTED!not-for-mail
From: nntp.mbourne@spamgourmet.com (Mark Bourne)
Newsgroups: comp.lang.python
Subject: Re: To clarify how Python handles two equal objects
Date: Sun, 15 Jan 2023 13:14:50 +0000
Organization: Aioe.org NNTP Server
Message-ID: <tq0u8b$179f$1@gioia.aioe.org>
References: <NLSPZV8--7-9@tutanota.com>
<31d2ed67-d710-cbb9-5e44-0872a07747c5@mrabarnett.plus.com>
<59d349a8-508c-cc7d-c833-d309d888d4c2@tompassin.net>
<NLSlYxA--B-9@tutanota.com>
<mailman.1474.1673389296.20444.python-list@python.org>
<k26hrvFjc02U1@mid.individual.net> <NLWSpB7--3-9@tutanota.com>
<3f5458ee-2084-dfef-a10a-e6a9ce959482@roelschroeven.net>
<NLX4p6f--3-9@tutanota.com> <00a801d927c1$a6b80730$f4281590$@gmail.com>
<NLmblKO--3-9@tutanota.com>
<mailman.1507.1673739055.20444.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="40239"; posting-host="Bz6wgdG13kDEF+8WFnpMfQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
SeaMonkey/2.53.14
X-Notice: Filtered by postfilter v. 0.9.2
 by: Mark Bourne - Sun, 15 Jan 2023 13:14 UTC

Jen Kris wrote:
> Avi,
>
> Your comments go farther afield than my original question, but you made some interesting additional points.  For example, I sometimes work with the C API and sys.getrefcount may be helpful in deciding when to INCREF and DECREF.  But that’s another issue.
>
> The situation I described in my original post is limited to a case such as x = y where both "x" and "y" are arrays – whether they are lists in Python, or from the array module – and the question in a compiled C extension is whether the assignment can be done simply by "x" taking the pointer to "y" rather than moving all the data from "y" into the memory buffer for "x" which, for a wide array, would be much more time consuming than just moving a pointer.  The other advantage to doing it that way is if, as in my case, we perform a math operation on any element in "x" then Python expects that the same change to be reflected in "y."  If I don’t use the same pointers then I would have to perform that operation twice – once for "x" and once  for "y" – in addition to the expense of moving all the data.
>
> The answers I got from this post confirmed that it I can use the pointer if "y" is not re-defined to something else during the lifespan of "x."  If it is then "x" has to be restored to its original pointer.  I did it that way, and helpfully the compiler did not overrule me.

I haven't done much with C extensions, but I don't think you'd need to
do anything with "x" in that case. If something else is assigned to
"y", "x" would still be a reference to the original object - why would
it need to be "restored" to anything? Unless I've misunderstood what's
going on here...

--
Mark.

RE: To clarify how Python handles two equal objects

<mailman.1516.1673806395.20444.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=25559&group=comp.lang.python#25559

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: <avi.e.gross@gmail.com>
Newsgroups: comp.lang.python
Subject: RE: To clarify how Python handles two equal objects
Date: Sun, 15 Jan 2023 13:13:09 -0500
Lines: 66
Message-ID: <mailman.1516.1673806395.20444.python-list@python.org>
References: <59d349a8-508c-cc7d-c833-d309d888d4c2@tompassin.net>
<NLSlYxA--B-9@tutanota.com>
<mailman.1474.1673389296.20444.python-list@python.org>
<k26hrvFjc02U1@mid.individual.net> <NLWSpB7--3-9@tutanota.com>
<3f5458ee-2084-dfef-a10a-e6a9ce959482@roelschroeven.net>
<NLX4p6f--3-9@tutanota.com> <00a801d927c1$a6b80730$f4281590$@gmail.com>
<NLmblKO--3-9@tutanota.com>
<CAPTjJmpR_a_+grai=uhukg9_Ub=5mWyZWxEk+M=HOC6J1w5nrA@mail.gmail.com>
<NLmrDPa--B-9@tutanota.com>
<CAPTjJmp8iBEzKsSmOzf5uV1jUD7sF4KqpjfabjBWpBk4U4hq7w@mail.gmail.com>
<415e4a55-2ce6-f4fc-7c2e-df4fd9e1e301@roelschroeven.net>
<2f398a79-f6e7-fa75-4462-e7ba838b375b@chagford.com>
<003a01d9290d$065fb6f0$131f24d0$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de 6V6h2NjvONcwQ9nMU5os+g4+8wxu8Gj09vrQPdmRpFnA==
Return-Path: <avi.e.gross@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=AeSt6gIr;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.047
X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; '2023': 0.07; 'clarify':
0.07; 'formal': 0.07; 'lecture': 0.07; '*not*': 0.09; 'aspect':
0.09; 'deeper': 0.09; 'expression': 0.09; 'moved': 0.09;
'properties': 0.09; 'received:108': 0.09; 'situations': 0.09;
'subject:how': 0.09; 'subject:two': 0.09; 'subject:Python': 0.12;
'url:mailman': 0.15; 'problem.': 0.15; 'determining': 0.16;
'does,': 0.16; 'encounter': 0.16; 'frank,': 0.16; 'humans': 0.16;
'in-line': 0.16; 'lambda': 0.16; 'mean.': 0.16; 'millman': 0.16;
'motor': 0.16; 'received:209.85.160.172': 0.16; 'received:mail-
qt1-f172.google.com': 0.16; 'yet?': 0.16; 'python': 0.16;
'larger': 0.17; 'probably': 0.17; 'message-id:@gmail.com': 0.18;
'name.': 0.19; 'to:addr:python-list': 0.20; 'language': 0.21;
'hall': 0.22; 'purposes': 0.22; 'skip:- 10': 0.25; 'url-
ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'url:listinfo': 0.25; 'url-ip:188.166/16': 0.25; 'object': 0.26;
'bit': 0.27; 'function': 0.27; 'seem': 0.31; 'raise': 0.31;
'received:209.85.160': 0.31; 'url-ip:188/8': 0.31; 'program':
0.31; 'think': 0.32; 'everyone': 0.32; 'question': 0.32;
'concept': 0.32; 'else,': 0.32; 'objects': 0.32; 'programmers':
0.32; 'python-list': 0.32; 'but': 0.32; 'same': 0.34; 'mean':
0.34; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'complex': 0.35; 'fine': 0.35; 'item': 0.35; 'runs': 0.35;
'understood': 0.35; 'usual': 0.35; 'yes,': 0.35;
'from:addr:gmail.com': 0.35; 'people': 0.36; 'special': 0.37;
'received:209.85': 0.37; 'class': 0.37; 'way': 0.38;
'received:209': 0.39; 'two': 0.39; 'list': 0.39; 'use': 0.39;
'on.': 0.39; 'happen': 0.40; 'situation': 0.40; 'want': 0.40;
'reference': 0.60; 'experienced': 0.61; 'from:': 0.62; 'to:':
0.62; 'here': 0.62; 'simply': 0.63; 'once': 0.63; 'between': 0.63;
'pass': 0.64; 'our': 0.64; 'key': 0.64; 're:': 0.64; 'came': 0.65;
'parts': 0.65; 'similar': 0.65; 'required': 0.65; 'years': 0.65;
'order': 0.69; 'and,': 0.69; 'blue': 0.69; 'discussing': 0.69;
'refers': 0.69; 'compared': 0.71; 'living': 0.71; 'january': 0.71;
'name,': 0.75; 'anonymous': 0.76; 'death': 0.76; 'handles': 0.76;
'sent:': 0.78; 'moment': 0.81; 'acquire': 0.84; 'guy': 0.84;
'beaten': 0.84; 'consequences': 0.84; 'discarded': 0.84; 'lose':
0.84; 'minds': 0.84; 'referenced': 0.84; 'talk.': 0.84; 'type,':
0.84; 'vehicles,': 0.84; 'exists': 0.91; 'number.': 0.91; 'pop':
0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=thread-index:content-language:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:from:to:cc:subject:date:message-id:reply-to;
bh=JKJ9vMVogHfu+fUZ5wRW8cboFAhugl0/yfVqMpTlFxU=;
b=AeSt6gIrrIaCp+UG73+cX+YPqjD9gnuOIpjt0Mabc8fOaNheXGnR38FucbkrQDWqEh
ykFh4WJo+S8wd5qviTYteH+WGuQQpMjNiPhUr3wUFCE1q9/pvlYkDzohxNB4u/L6t9qL
HmSoVWwWGJ/G4GxzeU4zD6bNyQAiU2rBVdGrKVL/2KsqRDOUSPGCXrFu0TZkd5B3zkHT
ZYxir16nTwUiRdCOglWHnN4VOpoyLJnIhkx3zsbTvtq2Cc5RyLozvpBzyqOUej0rnLTj
dLJW2PL9qSUU/+HjoG9Wxbp5Hk+y2bkzdiEpXqLUZuwepy4lLvr6anP7HlaF28CDsUXR
zWkw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=thread-index:content-language:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=JKJ9vMVogHfu+fUZ5wRW8cboFAhugl0/yfVqMpTlFxU=;
b=U0/6ACwJE56gJ9VOYtopIP++IiC2QPl9r56Sf+P3jlaSL7Dy4alHTYfM0TdUYFH1+Q
x3UpblhAMkL8FRYqPLf0aTlgrOHmxre6cGBjQtGL+TF8/9cSGOXumcBl8uEfqyZno3RJ
H1xYoSlkNW+Vzket+0JhDj7E7ltGaj8x0/RrN9hsC6Q9f2Zxep0LbqgO9TSCxkftYWEs
ju6Y4+JUAHSWURIqZTpaFOKSK/8OUygfUrcPJYDWCDGzqfXI0sfMcQV9rKtFbfoQAXeP
kUAgCCcprxvkGOYiYqhLphS6F9kt+8xmeI9zV0mdUfpGm5RPiU0xp7TOD29PdxfsNQ8o
AMfg==
X-Gm-Message-State: AFqh2kpBPbs3mITbg2yNpifyYZfsxmkuVXlE8QTYrBESnPz/btKlApda
gYBUEtz5Rr40UwJNoXOh+I+UaJOE97c=
X-Google-Smtp-Source: AMrXdXvUaN9qF8CX2ucSuoluDmUnp6KmJfbCTWKtGMj6HkLTPNZRXamLxXpxmGa2WgCe4uW3ucZ3AA==
X-Received: by 2002:a05:622a:5c8d:b0:3a9:81ba:409d with SMTP id
ge13-20020a05622a5c8d00b003a981ba409dmr126600849qtb.0.1673806392168;
Sun, 15 Jan 2023 10:13:12 -0800 (PST)
In-Reply-To: <2f398a79-f6e7-fa75-4462-e7ba838b375b@chagford.com>
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-us
Thread-Index: AQHLHAp1XOf3BE7OTBFA1bVGY+9s2wKaxvepAYZQ4OkCfGLWywGwErWNAemlleoCxAGsBgJRamZaAjIlJ2ECVktGggG/di4pAW51xToBuC1yeAL3ZR/Lrd5IHEA=
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <003a01d9290d$065fb6f0$131f24d0$@gmail.com>
X-Mailman-Original-References: <59d349a8-508c-cc7d-c833-d309d888d4c2@tompassin.net>
<NLSlYxA--B-9@tutanota.com>
<mailman.1474.1673389296.20444.python-list@python.org>
<k26hrvFjc02U1@mid.individual.net> <NLWSpB7--3-9@tutanota.com>
<3f5458ee-2084-dfef-a10a-e6a9ce959482@roelschroeven.net>
<NLX4p6f--3-9@tutanota.com> <00a801d927c1$a6b80730$f4281590$@gmail.com>
<NLmblKO--3-9@tutanota.com>
<CAPTjJmpR_a_+grai=uhukg9_Ub=5mWyZWxEk+M=HOC6J1w5nrA@mail.gmail.com>
<NLmrDPa--B-9@tutanota.com>
<CAPTjJmp8iBEzKsSmOzf5uV1jUD7sF4KqpjfabjBWpBk4U4hq7w@mail.gmail.com>
<415e4a55-2ce6-f4fc-7c2e-df4fd9e1e301@roelschroeven.net>
<2f398a79-f6e7-fa75-4462-e7ba838b375b@chagford.com>
 by: <avi.e.gross@gmail.com> - Sun, 15 Jan 2023 18:13 UTC

<<< Frank Millman>>> My 'aha' moment came when I understood that a python object has only three properties - a type, an id, and a value. It does *not* have a name.

Yes, Frank, it is a bit like how some people need to wrap their minds around a concept like an anonymous function. It has no name and for many purposes needs no name, but at the same time can be bound to one or more names if needed.

Some people will encounter a situation where you need to pass a function to be called such as a key function for determining the sort order and they will create a new function first the usual way with a name and then pass it along by name. That works fine but the function then persists while not being used again and even choosing a name can have consequences if the same name is already in use and so on.

Experienced programmers might use some kind of lambda expression in-line as the function as an object is then created, and passed along as a reference to be used and probably discarded once nothing refers to it.

Similar things can happen if an object is created as part of a larger complex such as a list or deque of them. Each item can be referenced unambiguously without having a formal name. You can pop off the next one an use it or ask to take the fifth. It may acquire and lose names as the program runs but sometimes can have many names or none.

Getting people to see that an object exists whether it has no name and to speak about them with that understanding can be a problem. We as humans seem to think we are our names. But I know my names have changed over the years partially because I moved between countries and I have several additional names used just for special purposes, and yet for some purposes I am simply a number. If I raise my class in a lecture hall where my name is not known, they may point at me or ask the guy in the blue short to talk. At the Department of Motor Vehicles, my name, like everyone else, is NEXT!

The real point is what Python does, not what other situations require. Two objects are equal does not always mean what you think or want it to mean. What we are discussing here is two objects loosely of type "name" that are being compared not for whether THEY are themselves equal as in the same symbols composing them and perhaps living in the same namespace. The question was about two objects that contained references to another object or even to different parts of another object. As it happens, that can be a deeper question in which some parts are not a required aspect of the language and may be part of one of many possible implementations. And, as noted, the names can be detached from that reference too so a link is not permanent.

Have we beaten this one to death yet?

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On Behalf Of Frank Millman
Sent: Sunday, January 15, 2023 12:47 AM
To: python-list@python.org
Subject: Re: To clarify how Python handles two equal objects

--
https://mail.python.org/mailman/listinfo/python-list


devel / comp.lang.python / RE: To clarify how Python handles two equal objects

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor