Re: Writing a C extension - borrowed references

2018-03-21 Thread Stefan Behnel
Tom Evans via Python-list schrieb am 20.03.2018 um 18:03: > On Tue, Mar 20, 2018 at 4:38 PM, Chris Angelico wrote: >> BTW, have you looked into Cython? It's smart enough to take care of a >> lot of this sort of thing for you. > > I did a bit; this work is to replace our old python 2 SAML client, >

Re: Writing a C extension - borrowed references

2018-03-20 Thread Tom Evans via Python-list
On Tue, Mar 20, 2018 at 5:36 PM, Rob Gaddi wrote: > If all you're doing is a thin-wrapper around a C library, have you thought > about just using ctypes? Yep; the C library whose API I'm using uses macros to cast things to the right structure, and (similar to Cython), as I already _have_ the code

Re: Writing a C extension - borrowed references

2018-03-20 Thread Rob Gaddi
On 03/20/2018 10:03 AM, Tom Evans wrote: On Tue, Mar 20, 2018 at 4:38 PM, Chris Angelico wrote: BTW, have you looked into Cython? It's smart enough to take care of a lot of this sort of thing for you. I did a bit; this work is to replace our old python 2 SAML client, which used python-lasso a

Re: Writing a C extension - borrowed references

2018-03-20 Thread Python
On Tue, Mar 20, 2018 at 04:33:15PM +, Paul Moore wrote: > Or, to put it another way, "if you need to ask, you can't afford to". If you don't know, you need to ask so that you can learn whether or not you can afford to. :( -- https://mail.python.org/mailman/listinfo/python-list

Re: Writing a C extension - borrowed references

2018-03-20 Thread Tom Evans via Python-list
On Tue, Mar 20, 2018 at 4:38 PM, Chris Angelico wrote: > BTW, have you looked into Cython? It's smart enough to take care of a > lot of this sort of thing for you. I did a bit; this work is to replace our old python 2 SAML client, which used python-lasso and python-libxml2, both packages that are

Re: Writing a C extension - borrowed references

2018-03-20 Thread Chris Angelico
On Wed, Mar 21, 2018 at 3:22 AM, Tom Evans via Python-list wrote: > Hi all > > I'm writing my first C extension for Python here, and all is going > well. However, I was reading [1], and the author there is advocating > Py_INCREF 'ing *every* borrowed reference. BTW, have you looked into Cython? I

Re: Writing a C extension - borrowed references

2018-03-20 Thread Chris Angelico
On Wed, Mar 21, 2018 at 3:22 AM, Tom Evans via Python-list wrote: > Hi all > > I'm writing my first C extension for Python here, and all is going > well. However, I was reading [1], and the author there is advocating > Py_INCREF 'ing *every* borrowed reference. > > Now, I get that if I do somethin

Re: Writing a C extension - borrowed references

2018-03-20 Thread Paul Moore
On 20 March 2018 at 16:22, Tom Evans via Python-list wrote: > Hi all > > I'm writing my first C extension for Python here, and all is going > well. However, I was reading [1], and the author there is advocating > Py_INCREF 'ing *every* borrowed reference. > > Now, I get that if I do something to m

Writing a C extension - borrowed references

2018-03-20 Thread Tom Evans via Python-list
Hi all I'm writing my first C extension for Python here, and all is going well. However, I was reading [1], and the author there is advocating Py_INCREF 'ing *every* borrowed reference. Now, I get that if I do something to mutate and perhaps invalidate the PyObject that was borrowed I can get unp