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

References <mailman.689.1303379230.9059.python-list@python.org> <23a890a7-aef1-4d5b-8dab-6e09c2792d4a@glegroupsg2000goo.googlegroups.com>
Date 2011-04-21 20:02 +1000
Subject Re: is there a difference between one line and many lines
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.692.1303380174.9059.python-list@python.org> (permalink)

Show all headers | 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