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?

From Stefan Behnel <stefan_ml@behnel.de>
Newsgroups comp.lang.python
Subject Re: How are you supposed to define subclasses in C?
Date 2016-04-21 19:56 +0200
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>

Show all headers | 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