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

Michael Foord fuzzyman at voidspace.org.uk
Thu Jul 8 03:57:10 CEST 2010


On 08/07/2010 02:45, Terry Reedy wrote:

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.getlongestmatching 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. Would it be possible to provide a single method in C by providing a C base class with a single method and have the full implementation inherit from the C base class if it is available or otherwise a pure Python base class?

Michael

-- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog

READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.



More information about the Python-Dev mailing list