Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98964

Re: Writing SOME class methods in C

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Newsgroups comp.lang.python
Subject Re: Writing SOME class methods in C
Date Wed, 18 Nov 2015 12:52:26 +0000
Lines 19
Message-ID <mailman.412.1447851580.16136.python-list@python.org> (permalink)
References <slrnn4obfa.db7.dh@dotcom.mfs32>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de iwDQh70UpcSxLSJI5eFHngOD7mJIJ5Fds0v7l8fGVsxQ==
Return-Path <oscar.j.benjamin@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'remaining': 0.07; 'cc:addr :python-list': 0.09; 'subclass': 0.09; 'subject:Writing': 0.09; 'python': 0.10; 'suggest': 0.15; '(but': 0.15; '07:50,': 0.16; 'cc:name:python list': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:class': 0.16; 'too).': 0.16; 'wrote:': 0.16; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'trying': 0.22; 'daniel': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'module': 0.25; "i've": 0.25; 'message-id:@mail.gmail.com': 0.27; 'methods.': 0.29; "i'm": 0.30; 'classes': 0.30; 'code': 0.30; 'implement': 0.32; 'compiled': 0.32; 'class': 0.33; 'add': 0.34; 'received:google.com': 0.35; 'done': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'modules': 0.36; 'subject:: ': 0.37; 'suggestion': 0.37; 'received:209': 0.38; 'some': 0.40; 'your': 0.60; 'entire': 0.61; 'here.': 0.62; '(that': 0.63; 'oscar': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=R6MCyKw1Y7ImAKaqkx70addxuWEdG8lblAfN2c3LlHE=; b=nAFshdomTnbQ8SkUXnMbzeErhQTATgOJCOpTU+4iEcb2RO/MvHIaOaCpz8KMQOBkQm cf6kJ/DX8I8hVSWN1xqDhK8RkNMtL6EM56EWtzLNQcsGRTdv4WLKw9LXe2lDVKLKsR7w DhGuaSDqiknrysqqZgVTz9F16lXXnyUPIxG4uZORG6Cvl1KGRr4T83aSAcpgXk3SKQUT JOBXgiTDmP1+rT+4QNU8x5/h7BG5vqnsHwvjPXiC3TJb5heBTODhiMAAT1mKR5DJn6sT yTJ0LPD3ivE+XEnL+YrAKAWxYs+m7vf9MRCbyXdFmBiRBQvctrGEZQTEvWO4gwOVlxfp TC2w==
X-Received by 10.25.81.13 with SMTP id f13mr652410lfb.126.1447851166663; Wed, 18 Nov 2015 04:52:46 -0800 (PST)
In-Reply-To <slrnn4obfa.db7.dh@dotcom.mfs32>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:98964

Show key headers only | View raw


On 18 November 2015 at 07:50, Daniel Haude <dh@dotcom.mfs32> 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.

Alternatively Terry's suggestion to implement a class in C and then
subclass it in Python to add the remaining methods is a good one. But
then I would write the C class using Cython so I may as well do the
whole thing in Cython.

--
Oscar

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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