Re: Can a simple a==b 'hang' in and endless loop?



On Wed, 18 Jan 2006 15:29:24 +0100, Claudio Grondi wrote:

> The problem here is, that I mean, that in Python it makes no sense to
> talk about a value of an object, because it leads to weird things when
> trying to give a definition what a value of an object is.

Python object: 1
The value of that Python object: the int 1

Python object 4.7
The value of that Python object: the float 4.7

Python object "abc"
The value of that Python object: a string consisting of characters a, b
and c.

Python object [1, 4.7, "abc"]
The value of that Python object: a list containing objects 1, 4.7 and "abc".


Where's the problem?


> It seems, that in Python there is a lack of operator able to compare
> values as it is the case in C and Javascript, simply because in Python
> there are no really such things as values, so there is no need to
> compare them.

>>> 1 == 1
True
>>> 4.7 == 1
False

Works for me.


> The higher level of abstraction/indirection in Python results in making
> the concepts of 'value', 'having a value' or 'comparing values' useless,
> where it helps in C to express the difference between address and
> content at that address and to distinguish between the information
> telling _what_ is stored in memory and the information about _where_ it
> is stored.

In Python, you never care _where_ anything is stored. The id() function
returns the unique ID of an object, which as an implementation detail may
be the actual memory address, but that's just an implementation detail. In
any case, given a memory address, you can't do anything with that
knowledge.


--
Steven.

.



Relevant Pages

  • Re: 2.6, 3.0, and truly independent intepreters
    ... just the GIL being in place, but of course it's there for a reason. ... Python faster on single core machines and more stable on multi core ... Other language designers think the same way. ... with languages that use memory pointers, have the potential to get out ...
    (comp.lang.python)
  • Re: why cannot assign to function call
    ... a porch the same if all its ... actual Python objects tend to be mutable only if they are ... In CPython, the id is given by the memory location of the object, which ... significant changes and replacements and add-ons that nevertheless don't ...
    (comp.lang.python)
  • Re: Writing huge Sets() to disk
    ... that this code takes a lot of extra memory. ... > I believe it's the references problem, ... It's a bit unfortunate that all those instance variables are global to ... it merely aggregates it for use in storing new Python objects. ...
    (comp.lang.python)
  • Re: Memory Leaks and Heapy
    ... I'm trying to plug some memory leaks in a TurboGears program. ... and simplejson for message passing between the server ... I'm using Heapy. ... means there are not many leaked objects in the python space. ...
    (comp.lang.python)
  • Re: Newbie completely confused
    ... Your program uses quite a bit of memory. ... And really, reading 30MB files should not be such a problem, right? ... 'del LINES' deletes the lines that are read from the file, but not all of your data structures that you created out of them. ... The python code loads a module written in C++ and some of the member variables actually point to C++ objects created dynamically, so one actually has to call their destructors before unbinding the python var. ...
    (comp.lang.python)