Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99693
| From | Stefan Behnel <stefan_ml@behnel.de> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Writing SOME class methods in C |
| Date | 2015-11-29 14:26 +0100 |
| Message-ID | <mailman.8.1448803612.14615.python-list@python.org> (permalink) |
| References | <slrnn4obfa.db7.dh@dotcom.mfs32> <CAHVvXxSEN5PYeJ==u=fWKxAkmsZXU8FhsFOFDQd_05T8M5OgBw@mail.gmail.com> |
Oscar Benjamin schrieb am 18.11.2015 um 13:52: > On 18 November 2015 at 07:50, Daniel Haude wrote: >> >> I'm trying to implement some (but not all) methods of a Python class in C. >> What I've found on the Net is: >> - how to implement entire modules in C so that I can import that module and >> use the C functions (successfully done it, too). >> - how to implement entire classes in C > > I would suggest to use Cython here. You can write your class in Python > (that will be compiled to C) and then call out to any C code from any > of its methods. Or, in fact, do the reverse: Implement the base class in Cython and inherit from it in a Python class that extends it. That would give you a fast, native extension type at the base and leaves you with all the freedom to extend it in Python code or even natively in other Cython code. I strongly recommend not to resort to writing real C code here (using the C-API of CPython). It will be slower and will contain more bugs. Stefan
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Writing SOME class methods in C Daniel Haude <dh@dotcom.mfs32> - 2015-11-18 07:50 +0000 Re: Writing SOME class methods in C Terry Reedy <tjreedy@udel.edu> - 2015-11-18 04:47 -0500 Re: Writing SOME class methods in C Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2015-11-18 12:52 +0000 Re: Writing SOME class methods in C Stefan Behnel <stefan_ml@behnel.de> - 2015-11-29 14:26 +0100
csiph-web