On Wed, 07 Jul 2010 21:45:30 -0400 Terry Reedy <tjre...@udel.edu> wrote: > > > 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.
And you still haven't understood my point. ctypes doesn't allow you to write any C code, only to interface with existing C code. So, regardless of whether get_longest_matching() is a function or method, it would have to be written in C manually, and that would certainly be in an extension module. (admittedly, you can instead make a pure C library with such a function and then wrap it with ctypes, but I don't see the point: you still have to write most C code yourself) > 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. And that's a wrong impression. Inheritance allows you to do that (see Michael's answer). Besides, you can also code that method as a helper function. It is not difficult to graft a function from a module into another module. Antoine. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com