Is 'everything' a refrence or isn't it?

David Murmann david.murmann at
Thu Jan 5 13:35:43 CET 2006

Ich schrieb:
> but i think python does
>  if (i == &_i2)
> because there is only one integer object holding the value 2, so
> it is sufficient to compare the addresses (i'm not sure about this,
> perhaps someone smarter can clarify?).

well, as far as i can see the relevant function is 

static int
int_compare(PyIntObject *v, PyIntObject *w)
	register long i = v->ob_ival;
	register long j = w->ob_ival;
	return (i < j) ? -1 : (i > j) ? 1 : 0;

in Objects/intobject.c, which does compare by value. so, this is
either special-cased elsewhere or not optimized (should/can it be?).


More information about the Python-list mailing list