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


Groups > comp.lang.python > #3781

Re: is there a difference between one line and many lines

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.033
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'cpython': 0.07; 'python': 0.07; '21,': 0.09; 'compares': 0.09; 'pm,': 0.11; 'win32': 0.12; 'wrote:': 0.14; '"is"': 0.16; 'guessing': 0.16; 'subject:between': 0.16; 'subject:lines': 0.16; 'sure,': 0.16; 'idle': 0.19; 'header :In-Reply-To:1': 0.22; 'thu,': 0.22; 'memory': 0.24; "i'm": 0.26; 'chris': 0.27; 'message-id:@mail.gmail.com': 0.28; "doesn't": 0.28; 'compiling': 0.31; 'separately.': 0.31; 'does': 0.31; 'sharing': 0.31; 'to:addr:python-list': 0.32; 'asking': 0.32; 'lines': 0.34; 'trouble': 0.34; 'decide': 0.34; 'difference': 0.35; 'there': 0.35; 'put': 0.35; 'running': 0.36; 'case,': 0.36; 'two': 0.37; 'some': 0.37; 'received:209.85': 0.37; 'apr': 0.38; 'depend': 0.38; 'locate': 0.38; 'received:google.com': 0.38; 'happens': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.39; "it's": 0.40; 'header:Received:5': 0.40; '2011': 0.62; 'cause': 0.65; 'saving': 0.72; 'subject:line': 0.73; 'subject:one': 0.73; '256': 0.84; 'received:209.85.210.174': 0.84; 'received:mail- iy0-f174.google.com': 0.84; 'subject:there': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=EIA7VlBA1Lty3i2grSQGK5vCXRF00Co8vintpUrjsvQ=; b=SBbJ6Vix4DDfNoR4TuYXzVd3oUtxbZajgzYjcPJfGSy1XcigvANA/SULU2t3RPQv0x G2FKWK75+2Fd2s3yensHJLfCevcG/dOGCTfT9h7rcrv0/DvX4z4LiaXe8Zwil8GzdsLm efPxtnW963m2CLEB7N0+SnqBaMgQvZ1qZt6JQ=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=fSH3Rxs/hdGDXETZRe78tSySMg07cQcfB0PJGH5fujH8c9qxfjm2iIohWPFI8iIdjb yFFXWCui8bRxlOyjVBk0JRnFhBj7c4NR988oMVrIBm0/0BApFBk91YWUXIQrlsVtjqqb 3NEvSCW+//XssAU0mz8opfrqpugNzV50A+19w=
MIME-Version 1.0
In-Reply-To <23a890a7-aef1-4d5b-8dab-6e09c2792d4a@glegroupsg2000goo.googlegroups.com>
References <mailman.689.1303379230.9059.python-list@python.org> <23a890a7-aef1-4d5b-8dab-6e09c2792d4a@glegroupsg2000goo.googlegroups.com>
Date Thu, 21 Apr 2011 20:02:52 +1000
Subject Re: is there a difference between one line and many lines
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.692.1303380174.9059.python-list@python.org> (permalink)
Lines 13
NNTP-Posting-Host 82.94.164.166
X-Trace 1303380175 news.xs4all.nl 81475 [::ffff:82.94.164.166]:43582
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:3781

Show key headers only | View raw


On Thu, Apr 21, 2011 at 7:55 PM, vino19 <vinograd19@gmail.com> wrote:
> Sure, I understand that "is" is not "==", cause "is" just compares id(a)==id(b).
>
> I have a win32 CPython and the range of "singletons" is from -5 to 256 on my machine.
>
> I am asking about what happens in Python interpreter? Why is there a difference between running one line like "a=1;b=1" and two lines like "a=1 \n b=1"? Does it decide to locate memory in different types depend on a code?

Ah okay! In that case, I'm guessing this is going to be an oddity of
the IDLE system, because it's compiling each line separately. When you
put it on a single line, it's saving some trouble by sharing the
constant; when you do them separately, it doesn't optimize like that.

Chris Angelico

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: is there a difference between one line and many lines vino19 <vinograd19@gmail.com> - 2011-04-21 02:55 -0700
  Re: is there a difference between one line and many lines Heiko Wundram <modelnine@modelnine.org> - 2011-04-21 11:59 +0200
  Re: is there a difference between one line and many lines Chris Angelico <rosuav@gmail.com> - 2011-04-21 20:02 +1000
  Re: is there a difference between one line and many lines Heiko Wundram <modelnine@modelnine.org> - 2011-04-21 12:19 +0200
  Re: is there a difference between one line and many lines Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-04-21 12:39 +0200

csiph-web