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


Groups > comp.lang.python > #107462 > unrolled thread

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

Started byStefan Behnel <stefan_ml@behnel.de>
First post2016-04-21 19:56 +0200
Last post2016-04-21 19:56 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

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

FromStefan Behnel <stefan_ml@behnel.de>
Date2016-04-21 19:56 +0200
SubjectRe: How are you supposed to define subclasses in C?
Message-ID<mailman.23.1461261796.23626.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web