Suresh Jeevanandam wrote:
> # I am new to python.
[...]
> In any application most of the operation is numerical. So, i think, we
> should get a good speed advantage with the availability of mutable
> numbers. What do you think ?
If you are new to Python, I think you should try to learn how to
us
Rocco> def f():
Rocco> a = 12100
Rocco> b = 12100
Rocco> c = 121*100
Rocco> print a is b
Rocco> print a is c
That the object with value 12100 is referenced by both a and b is a side
effect of byte code compilation by CPython not an inherent property
Steve Holden wrote:
> fraca7 wrote:
>
>> The memory allocation for integers is optimized. 'Small' integers
>> (between -5 and 100 IIRC) are allocated once and reused. The memory
>> for larger integers is allocated once and reused whenever possible, so
>> the malloc() overhead is negligible.
>
fraca7 a écrit :
> Steve Holden a écrit :
>
>> [Thinks: or maybe fraca7 just meant that integers will be garbage
>> collected when there are no more references to them].
>
> Actually I meant that the memory is reused, but the same integer won't
> always have the same address.
And of course thi
Steve Holden a écrit :
> [Thinks: or maybe fraca7 just meant that integers will be garbage
> collected when there are no more references to them].
Actually I meant that the memory is reused, but the same integer won't
always have the same address.
I guess that in your example, the '121' is ass
On Tue, 21 Feb 2006 12:44:52 +0530 in comp.lang.python, Suresh
Jeevanandam <[EMAIL PROTECTED]> wrote:
># I am new to python.
>
>In python all numbers are immutable. This means there is one object ( a
>region in the memory ) created every time we do an numeric operation. I
>hope there should have
Steve Holden wrote:
> > The memory allocation for integers is optimized. 'Small' integers
> > (between -5 and 100 IIRC) are allocated once and reused. The memory for
> > larger integers is allocated once and reused whenever possible, so the
> > malloc() overhead is negligible.
>
> The first bit's
Steve Holden wrote:
> > The memory allocation for integers is optimized. 'Small' integers
> > (between -5 and 100 IIRC) are allocated once and reused. The memory for
> > larger integers is allocated once and reused whenever possible, so the
> > malloc() overhead is negligible.
>
> The first bit's
fraca7 wrote:
> Suresh Jeevanandam a écrit :
>
>># I am new to python.
>>
>>In python all numbers are immutable. This means there is one object ( a
>>region in the memory ) created every time we do an numeric operation. I
>>hope there should have been some good reasons why it was designed this w
fraca7 wrote:
> Suresh Jeevanandam a écrit :
>
>># I am new to python.
>>
>>In python all numbers are immutable. This means there is one object ( a
>>region in the memory ) created every time we do an numeric operation. I
>>hope there should have been some good reasons why it was designed this w
Suresh Jeevanandam a écrit :
> # I am new to python.
>
> In python all numbers are immutable. This means there is one object ( a
> region in the memory ) created every time we do an numeric operation. I
> hope there should have been some good reasons why it was designed this way.
The memory all
Suresh Jeevanandam wrote:
> In python all numbers are immutable.
True.
> This means there is one object (
> a region in the memory ) created every time we do an numeric
> operation.
False. Memory regions can be pooled in a way that "allocation" is a O(1)
operation.
> I hope there should have b
Suresh Jeevanandam wrote:
> But why not have mutable numbers also in the language.
The short answer I'd give is probably that this is so easy to do with a
user-defined class that it's never been all that pressing.
> In any application most of the operation is numerical. So, i think, we
> shoul
13 matches
Mail list logo