Re: The Folly of Python

Liste des GroupesRevenir à col advocacy 
Sujet : Re: The Folly of Python
De : nospam (at) *nospam* dfs.com (DFS)
Groupes : comp.os.linux.advocacy
Date : 16. Apr 2024, 04:52:21
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <uvkp55$nrtd$1@dont-email.me>
References : 1 2 3 4 5 6
User-Agent : Betterbird (Windows)
On 4/15/2024 10:09 PM, rbowman wrote:
On Mon, 15 Apr 2024 21:16:46 -0400, DFS wrote:
 
What do you notice about those id numbers?
 
for i in range(1000, 1011): print("int %d, id = %d" % (i, id(i)))
...
int 1000, id = 133523511399088
int 1001, id = 133523511399056
int 1002, id = 133523511399088
int 1003, id = 133523511399056
int 1004, id = 133523511399088
int 1005, id = 133523511399056
int 1006, id = 133523511399088
int 1007, id = 133523511399056
int 1008, id = 133523511399088
int 1009, id = 133523511399056
int 1010, id = 133523511399088
reference counts come and reference counts go

or, for extra credit explain
 
for i in range(250, 261): print("int %d, id = %d" % (i, id(i)))
...
int 250, id = 133523513024528
int 251, id = 133523513024560
int 252, id = 133523513024592
int 253, id = 133523513024624
int 254, id = 133523513024656
int 255, id = 133523513024688
int 256, id = 133523513024720
-5 to 255 are pre-allocated by CPython

int 257, id = 133523511399088
int 258, id = 133523511398960
int 259, id = 133523511399088
int 260, id = 133523511398960
 

Date Sujet#  Auteur
5 Oct 24 o 

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal