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

Claudio Grondi claudio.grondi at freenet.de
Thu Jan 19 11:44:22 EST 2006


Steve Holden wrote:
> Claudio Grondi wrote:
> 
>> Steven D'Aprano wrote:
> 
> [...]
> 
>>>> 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.
>>
>>
>>
>> The question here is, if this a handicap or a welcome feature?
>>
> A welcome feature, absolutely no doubt about it.
> 
>>  From the one side I am glad that Python cares about memory allocation 
>> for me, but on the other side I have trouble to accept, that I have no 
>> direct access to the memory area where data are stored in order to 
>> manipulate them. Having this possibility would enormously speed up 
>> some conversions, because it were possible to get them down to a 
>> redefinition of the data structure without being forced to loop over 
>> the actual content or use a special extension library written in C for 
>> doing that.
>>
> Well, if this isn't a case of premature optimization I've never seen 
> one. You apparently haven't yet written a single line of your 
> appliction, yet you are already concerned about its efficiency.
Wrong guess.
> 
> 1. First, make it work.
I did.
> 
> 2. Then, if it doesn;t work fast enough, make it work faster.
I did it, too.

Exactly in this order.

And out of this experience I mean to know, that it seems to be no other 
way for fast conversions as using own extension modules or existing 
ones. But if it necessary to use more than one existing extension module 
and the modules used are not compatible to each other, the problem 
persists.
And because I haven't mastered to write an own CPython extension module 
yet, my idea was to try to understand how Python works under the hood in 
order to find a workaround, but it seems, that there is none, so I have 
to master Pyrex first, then the problems will go away, right?

In other words, there is no way to avoid C programming in case available 
extension modules don't fit as solution for the task where speed 
matters, because there is no low level access to the data in Python.

In this context I wish Python would have an 'advanced mode' I could 
switch to, to get low level access to the data - is it a bad idea?

Claudio
> 
> regards
>  Steve



More information about the Python-list mailing list