about id()... 
Author Message
 about id()...

Hmm.  Blah:

  for a in range(150):
    if id(a) != id(a+0): print a

gives me numbers from 100 to 149.

Why is this?  It's some internal magick on Python's part, isn't it...

--

http://www.*-*-*.com/ ~japhy/                   http://www.*-*-*.com/
PerlMonth - An Online Perl Magazine             http://www.*-*-*.com/
The Perl Archive - Articles, Forums, etc.     http://www.*-*-*.com/



Wed, 04 Sep 2002 03:00:00 GMT  
 about id()...
Jeff Pinyan talks to himself...

Quote:
> Hmm.  Blah:

>   for a in range(150):
>     if id(a) != id(a+0): print a

> gives me numbers from 100 to 149.

> Why is this?  It's some internal magick on Python's part, isn't it...

Yep. The ints < 100 are interned. The fact that the limit is not
256 says something interesting about Guido...

- Gordon



Wed, 04 Sep 2002 03:00:00 GMT  
 about id()...

Quote:

> Hmm.  Blah:

>   for a in range(150):
>     if id(a) != id(a+0): print a

> gives me numbers from 100 to 149.

> Why is this?  It's some internal magick on Python's part, isn't it...

If a and b are immutables, then it is only guranteed that id(a) == id(b)
implies a == b. python can do whatever it wants, other then that.

--

http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com



Thu, 05 Sep 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. select count(*) from test_file where id>100 and id<1000

2. Object IDs are good ( was: Object IDs are bad )

3. Testing if ID is a VALID TSO ID

4. expect_after executes for spawn id 1 even if the corresponding expect executes for spawn id 2

5. User and Group name => user id and group id

6. id(a) == id(b) and a is not b --> bug?

7. Clean your PC properly - b79f4gt5biw id

8. CPU id in TCB

9. Your ID

10. Country ID

11. Need to locate unique task ID in MVS

12. Getting process ID under NT

 

 
Powered by phpBB® Forum Software