[Python-Dev] Python equivalents in stdlib Was: Include datetime.py in stdlib or not?

Terry Reedy tjreedy at udel.edu
Thu Jul 8 03:45:30 CEST 2010


On 7/7/2010 2:42 PM, Antoine Pitrou wrote:

I wrote
>> 4. Does not ctypes make it possible to replace a method of a Python-coded
>> class with a faster C version, with something like
>>    try:
>>      connect to methods.dll

methods.dll to be written

>>      check that function xyx exists
>>      replace Someclass.xyy with ctypes wrapper
>>    except: pass
>> For instance, the SequenceMatcher heuristic was added to speedup the
>> matching process that I believe is encapsulated in one O(n**2) or so
>> bottleneck method. I believe most everything else is O(n) bookkeeping.

> Except that ctypes doesn't help provide C extensions at all. It only
> helps provide wrappers around existing C libraries, which is quite a
> different thing.
> Which, in the end, makes the original suggestion meaningless.

To you, so let me restate it. It would be easier for many people to only 
rewrite, for instance,  difflib.SequenceMatcher.get_longest_matching in 
C than to rewrite the whole SequenceMatcher class, let alone the whole 
difflib module.

I got the impression from the datetime issue tracker discussion that it 
is not possible to replace a single method of a Python-coded class with 
a C version. I got this from statement that seems to say that having 
parallel Python and C versions is a nuisance because one must replace 
large chunks of Python, at least a class if not the whole module. If 
that impression is wrong, and I hope it is, the suggestion is unnecessary.

If it is right, then replacing the Python-coded function with a 
Python-coded wrapper for a function in a miscellaneous shared library 
might be both possible and useful. But again, if the premise is wrong, 
skip the conclusion.

-- 
Terry Jan Reedy



More information about the Python-Dev mailing list