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


Groups > comp.lang.python > #107462

Re: How are you supposed to define subclasses in C?

Path csiph.com!feeder.erje.net!2.eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From Stefan Behnel <stefan_ml@behnel.de>
Newsgroups comp.lang.python
Subject Re: How are you supposed to define subclasses in C?
Date Thu, 21 Apr 2016 19:56:19 +0200
Lines 23
Message-ID <mailman.23.1461261796.23626.python-list@python.org> (permalink)
References <1461256556.38223.585724489.051B2155@webmail.messagingengine.com> <nfb484$32v$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de yOO0qRrrjm3EMgAs6Ml3dwIRJuGIQV2uRDEP88zu2tqw==
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'sys': 0.05; 'ugly': 0.07; 'subject:How': 0.09; 'leaks': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'assume': 0.11; 'syntax': 0.13; '...)': 0.16; 'descriptors': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:subclasses': 0.16; 'module,': 0.18; 'stefan': 0.18; 'extension': 0.20; 'suppose': 0.22; 'trying': 0.22; 'tried': 0.24; 'examples': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'skip:" 20': 0.26; 'figure': 0.27; '(e.g.': 0.27; 'define': 0.27; 'code': 0.30; 'received:84': 0.32; 'lets': 0.33; 'skip:p 30': 0.35; 'but': 0.36; 'instead': 0.36; 'url:org': 0.36; 'faster': 0.36; 'to:addr:python- list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'things': 0.38; 'skip:p 20': 0.38; 'takes': 0.39; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'some': 0.40; 'care': 0.60; 'making': 0.62; 'beautiful': 0.66; 'hand.': 0.84; 'subject:you': 0.85
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host dslb-084-056-050-092.084.056.pools.vodafone-ip.de
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0
In-Reply-To <1461256556.38223.585724489.051B2155@webmail.messagingengine.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
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>
X-Mailman-Original-Message-ID <nfb484$32v$1@ger.gmane.org>
X-Mailman-Original-References <1461256556.38223.585724489.051B2155@webmail.messagingengine.com>
Xref csiph.com comp.lang.python:107462

Show key headers only | View raw


Random832 schrieb am 21.04.2016 um 18:35:
> I was trying to write a proof of concept on including descriptors (e.g.
> a "sys.recursionlimit" instead of set/get methods) in the sys module,
> and couldn't figure out how to "properly" define a type using
> PyType_FromSpecWithBases. Everything I tried just segfaulted. I ended up
> just calling PyObject_CallFunctionObjArgs((PyObject *)&PyType_Type, ...)
> but I assume there's a better way to do it. I couldn't find any examples
> or tutorial.

I suppose you might find Cython useful:

http://cython.org/

http://docs.cython.org/

In a nutshell, it lets you write beautiful Python code instead of ugly C
code full of leaks and crashes, and then takes care of making it faster
than the usual C-API calls you'd write by hand. It has some extended syntax
for extension types and other C-ish things to make their usage explicit.

Stefan

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


Thread

Re: How are you supposed to define subclasses in C? Stefan Behnel <stefan_ml@behnel.de> - 2016-04-21 19:56 +0200

csiph-web