cfbolz changed the topic of #pypy to: PyPy, the flexible snake (IRC logs: https://botbot.me/freenode/pypy/ ) | use cffi for calling C | mac OS and Fedora are not Windows
speeder39_ has joined #pypy
lritter has quit [Remote host closed the connection]
jcea has quit [Remote host closed the connection]
jcea has joined #pypy
bbot2 has joined #pypy
<bbot2> Started: http://buildbot.pypy.org/builders/pypy-c-jit-linux-x86-64/builds/5781 [ronan: force build, apptest-file]
<bbot2> Started: http://buildbot.pypy.org/builders/own-linux-x86-64/builds/7064 [ronan: force build, apptest-file]
jcea has quit [Quit: jcea]
<bbot2> Failure: http://buildbot.pypy.org/builders/own-linux-x86-64/builds/7064 [ronan: force build, apptest-file]
forgottenone has joined #pypy
<bbot2> Success: http://buildbot.pypy.org/builders/pypy-c-jit-linux-x86-64/builds/5781 [ronan: force build, apptest-file]
irclogs_io_bot has quit [Remote host closed the connection]
irclogs_io_bot has joined #pypy
_whitelogger has joined #pypy
speeder39_ has quit [Quit: Connection closed for inactivity]
dddddd has quit [Remote host closed the connection]
arigato has joined #pypy
arigato has quit [Ping timeout: 245 seconds]
arigato has joined #pypy
arigato has quit [Ping timeout: 268 seconds]
arigato has joined #pypy
_whitelogger has joined #pypy
Zaab1t has joined #pypy
smvv has joined #pypy
jcea has joined #pypy
arigato has quit [Remote host closed the connection]
lritter has joined #pypy
dddddd has joined #pypy
thnee has quit [Quit: WeeChat 1.9.1]
<rjarry> hey all
<rjarry> I have a C lib function that returns an allocated struct pointer
<rjarry> how can I control how this pointer is freed when the python refcount reaches 0 ?
<rjarry> I mean, is there a way to tell what function should be called to free the pointer
<rjarry> ?
<simpson> rjarry: Yeah, there's a custom allocator hook. Lemme find the docs.
<rjarry> I had looked at this, but it does not fit with what I need
<rjarry> hi simpson :)
<rjarry> the object is not allocated with ffi.new()
<rjarry> here's an example, I have a C function: struct my_complex_struct *get_data(const void *params);
<rjarry> and I also have
<rjarry> void free_complex_struct(struct my_complex_struct *);
<rjarry> from python, if I call: s = lib.get_data(xxx)
<rjarry> how can I make sure that lib.free_complex_struct(s) is called when the refcount reaches 0 ?
<rjarry> (or maybe I misunderstood something)
<simpson> rjarry: Then I think that you want ffi.gc()? https://cffi.readthedocs.io/en/latest/ref.html#ffi-gc
<rjarry> oh awesome, thanks simpson
<ronan> rjarry: or you can just write a class with a __del__, or (better) use a context manager
<rjarry> ronan, can you give me an example ?
<ronan> rjarry: this looks like a pretty complete example: https://github.com/dw/py-lmdb/blob/master/lmdb/cffi.py#L1497
<ronan> this is a class that does both: uses __del__ and can be used with 'with:'
<ronan> but the basic idea is just to call lib.get_data() from __init__() and lib.free_complex_struct() from __del__()
<ronan> (which is equivalent to what ffi.gc() does)
__pv has quit [Remote host closed the connection]
<bbot2> Started: http://buildbot.pypy.org/builders/pypy-c-jit-linux-x86-64/builds/5782 [ronan: force build, apptest-file]
<bbot2> Started: http://buildbot.pypy.org/builders/own-linux-x86-64/builds/7065 [ronan: force build, apptest-file]
<bbot2> Started: http://buildbot.pypy.org/builders/pypy-c-jit-win-x86-32/builds/4210 [ronan: force build, apptest-file]
<bbot2> Started: http://buildbot.pypy.org/builders/own-win-x86-32/builds/1882 [ronan: force build, apptest-file]
<bbot2> Started: http://buildbot.pypy.org/builders/pypy-c-jit-macosx-x86-64/builds/4047 [ronan: force build, apptest-file]
smvv has quit [Quit: Connection closed for inactivity]
<bbot2> Failure: http://buildbot.pypy.org/builders/own-linux-x86-64/builds/7065 [ronan: force build, apptest-file]
dddddd has quit [Remote host closed the connection]
<bbot2> Success: http://buildbot.pypy.org/builders/pypy-c-jit-linux-x86-64/builds/5782 [ronan: force build, apptest-file]
<bbot2> Failure: http://buildbot.pypy.org/builders/pypy-c-jit-macosx-x86-64/builds/4047 [ronan: force build, apptest-file]
__pv has joined #pypy
<bbot2> Failure: http://buildbot.pypy.org/builders/pypy-c-jit-win-x86-32/builds/4210 [ronan: force build, apptest-file]
themsay has joined #pypy
themsay has quit [Ping timeout: 252 seconds]
Zaab1t has quit [Quit: bye bye friends]
<bbot2> Failure: http://buildbot.pypy.org/builders/own-win-x86-32/builds/1882 [ronan: force build, apptest-file]
jamesaxl has quit [Quit: WeeChat 2.2]
lritter has quit [Quit: Leaving]
jacob22__ has quit [Remote host closed the connection]