Re: [Python] copy and id() function

2009-10-13 Per discussione Marco Beri
2009/10/13 Andrea Gasparini > Marco Beri spiffera, Tuesday 13 October 2009 circa: > > Ok ma l'importante è che sia chiaro che non esiste il corrispondente > > dell'operatore * di C :-) > > > > Il bello di Python è che ti puoi dimenticare di puntatori, di allocare > > (e poi rilasciare) la memoria

Re: [Python] copy and id() function

2009-10-13 Per discussione Andrea Gasparini
Marco Beri spiffera, Tuesday 13 October 2009 circa: > Ok ma l'importante è che sia chiaro che non esiste il corrispondente > dell'operatore * di C :-) > > Il bello di Python è che ti puoi dimenticare di puntatori, di allocare > (e poi rilasciare) la memoria, ecc. Beh, non intendevo dire che poi l

Re: [Python] copy and id() function

2009-10-13 Per discussione Marco Beri
On Tue, Oct 13, 2009 at 11:30 AM, Andrea Gasparini wrote: > More in general, we don't understand the behavior of the id() function. > > Doesn't return the object identity (object adress memory)?? > > Si', ritorna esattamente quello. > > > Why the object identity of the three variables in the follo

Re: [Python] copy and id() function

2009-10-13 Per discussione Marco Mariani
Alice Invernizzi wrote: > print 'id(a):', id(a), 'id(b):', id(b), 'id(c): ',id(c) > id(a): 9985904 (ok) > id(b): 9985904 (???) > id(c): 9985904 (???) > Alcuni numeri sono oggetti pre-allocati, pensa ad una cache per gli interi di uso comune. Questo e' in cache: > >>> a = 23 > >>> a is 23 > Tr

Re: [Python] copy and id() function

2009-10-13 Per discussione Andrea Gasparini
> Dear all, Ciao, credo che possiamo scrivere in italiano, giusto? ;) Allora, la cosa che forse non è chiara, è che in python i nomi delle variabili sono semplici "riferimenti" a un oggetto, non corrispondono all'oggetto stesso. Esempio semplice che spero possa chiarire: >>> a = [1,2,3] >>> b

[Python] copy and id() function

2009-10-13 Per discussione Alice Invernizzi
Dear all, we have a doubt concerning the list copying and the id function applied to a copied element of a list. - shallow copy: produce a new object that is not linked to the native object. Slicing on a list produces a shallow copy of the original one. - deep copy: bit-bit copy (in other words