Python Written in C?

Larry Bates larry.bates at websafe.com`
Tue Jul 22 23:42:51 EDT 2008


Marc 'BlackJack' Rintsch wrote:
> On Mon, 21 Jul 2008 18:12:54 +0200, mk wrote:
> 
>> Seriously, though, would there be any advantage in re-implementing 
>> Python in e.g. C++?
>>
>> Not that current implementation is bad, anything but, but if you're not 
>> careful, the fact that lists are implemented as C arrays can bite your 
>> rear from time to time (it recently bit mine while using lxml). Suppose 
>> C++ re-implementation used some other data structure (like linked list, 
>> possibly with twists like having an array containing pointers to 1st 
>> linked list elements to speed lookups up), which would be a bit slower 
>> on average perhaps, but it would behave better re deletion?
> 
> An operation that most people avoid because of the penalty of "shifting
> down" all elements after the deleted one.  Pythonistas tend to build new
> lists without unwanted elements instead.  I can't even remember when I
> deleted something from a list in the past.
> 
> Ciao,
> 	Marc 'BlackJack' Rintsch

When I use os.walk and need to remove directories or files.  Seems to be the 
only way to do the in-place delete that is required.  But you are right, it is 
very seldom.

-Larry



More information about the Python-list mailing list