Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52324

Re: Python Basic Doubt

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.06; 'variables': 0.07; 'assigning': 0.09; 'integers': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'cached': 0.16; 'message-id:@4ax.com': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sat,': 0.16; '>>>': 0.22; 'aug': 0.22; 'url:home': 0.24; 'header:X-Complaints-To:1': 0.27; '>>>>': 0.31; 'ok.': 0.31; 'but': 0.35; 'charset:us-ascii': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'most': 0.60; 'new': 0.61; 'address': 0.63; 'taking': 0.65; 'compare:': 0.84; 'location?': 0.84; 'received:108': 0.93; '2013': 0.98
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Python Basic Doubt
Date Sat, 10 Aug 2013 16:30:51 -0400
Organization IISS Elusive Unicorn
References <CAL0E0u6wO_UBniWoSpePvhKhPDG_nf4p1rqYYrGwzoHTqp6ZHA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-108-68-178-245.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.439.1376166663.1251.python-list@python.org> (permalink)
Lines 48
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1376166663 news.xs4all.nl 15992 [2001:888:2000:d::a6]:57060
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52324

Show key headers only | View raw


On Sat, 10 Aug 2013 21:03:36 +0530, Krishnan Shankar
<i.am.songoku@gmail.com> declaimed the following:

>
>>>> a=10
>>>> id(a)
>21665504
>>>> b=a
>>>> id(b)
>21665504
>>>> c=10
>>>> id(c)
>21665504
>
>I am actually assigning new value to c. But from the value of id() all
>three variables take same location. With variables a and b it is ok. But
>why c taking the same location?
>

	Because id(n) is not giving you the address of the NAME. It is giving
you the address of the "10" -- and small integers are cached and reused in
most Python implementations.

	Compare:

>>> a = 12345
>>> id(a)
56674472L
>>> b = a
>>> id(b)
56674472L
>>> c = 12345
>>> id(c)
56674688L
>>> a = 11
>>> id(a)
4472248L
>>> b = a
>>> id(b)
4472248L
>>> c = 11
>>> id(c)
4472248L
>>> 
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Python Basic Doubt Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-08-10 16:30 -0400
  Re: Python Basic Doubt Roy Smith <roy@panix.com> - 2013-08-10 16:42 -0400
    Re: Python Basic Doubt Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-11 08:29 +0000

csiph-web