antocuni changed the topic of #pypy to: PyPy, the flexible snake (IRC logs: https://botbot.me/freenode/pypy/ ) | use cffi for calling C | "PyPy: the Gradual Reduction of Magic (tm)"
lritter has quit [Quit: Leaving]
yuyichao_ has quit [Ping timeout: 256 seconds]
marr has quit [Ping timeout: 260 seconds]
tbodt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tbodt has joined #pypy
tbodt has quit [Client Quit]
TheAdversary has quit [Disconnected by services]
TheAdversary has joined #pypy
jcea has quit [Quit: jcea]
forgottenone has joined #pypy
yuyichao_ has joined #pypy
dddddd has quit [Read error: Connection reset by peer]
Joghurt_ has joined #pypy
Joghurt has quit [Ping timeout: 256 seconds]
Joghurt_ has quit [Ping timeout: 240 seconds]
forgottenone has quit [Ping timeout: 276 seconds]
wleslie has joined #pypy
Garen has quit [Read error: Connection reset by peer]
Garen has joined #pypy
oberstet has joined #pypy
jamadden has quit [Quit: Leaving.]
drolando has quit [Remote host closed the connection]
drolando has joined #pypy
cjwelborn has joined #pypy
jamadden has joined #pypy
wleslie has quit [Quit: ~~~ Crash in JIT!]
jamadden has quit [Ping timeout: 248 seconds]
jamesaxl has joined #pypy
raynold has quit [Quit: Connection closed for inactivity]
oberstet has quit [Ping timeout: 268 seconds]
marr has joined #pypy
lesshaste has joined #pypy
jamadden has joined #pypy
jamadden has quit [Client Quit]
oberstet has joined #pypy
dddddd has joined #pypy
jamadden has joined #pypy
marky1991 has joined #pypy
xqb has quit [Remote host closed the connection]
xqb has joined #pypy
xqb has quit [Remote host closed the connection]
jcea has joined #pypy
<kenaan_> barrywhart 2634_datetime_timedelta_performance 6513e6af0511 /lib_pypy/datetime.py: Implement __iadd__ and __isub__ on datetime objects
<kenaan_> barrywhart 2634_datetime_timedelta_performance 9aba94e5fe7c /lib_pypy/datetime.py: Remove __iadd__ and __isub__ functions. Add streamlined path in datetime.__new__.
<kenaan_> barrywhart 2634_datetime_timedelta_performance ac4aeeed1bd1 /lib_pypy/datetime.py: Fix accidental change
<kenaan_> barrywhart 2634_datetime_timedelta_performance eed3086fd841 /lib_pypy/datetime.py: Use new construction method in _from_timestamp
<kenaan_> cfbolz 2634_datetime_timedelta_performance 2a0f482a854d /lib_pypy/datetime.py: modify __new__ less invasively
<kenaan_> cfbolz default 2f5eb5410769 /lib_pypy/datetime.py: merge 2634_datetime_timedelta_performance improve the performance of datetime + timedelta by skipping the consist...
jcea has quit [Remote host closed the connection]
jcea has joined #pypy
Hotpot33 has quit [Max SendQ exceeded]
Hotpot33 has joined #pypy
xqb has joined #pypy
marky1991 has quit [Remote host closed the connection]
marky1991 has joined #pypy
marky1991 has quit [Remote host closed the connection]
marky1991 has joined #pypy
marky1991 has quit [Ping timeout: 248 seconds]
marky1991 has joined #pypy
marky1991 has quit [Remote host closed the connection]
marky1991 has joined #pypy
Guest54763 has quit [Remote host closed the connection]
marvin has joined #pypy
marky1991 has quit [Ping timeout: 265 seconds]
marvin is now known as Guest921
solarjoe4 has joined #pypy
Guest921 has quit [Remote host closed the connection]
lritter has joined #pypy
marvin has joined #pypy
marvin is now known as Guest21054
antocuni has joined #pypy
<solarjoe4> i need to put a structured numpy array into an array of C structs. y = ffi.from_buffer(x) works and returns a char[]. (why a char[], isn't this a pointer?) what would be the next step? i tried ffi.cast(mystruct*, y) or initialize ffi.new("mystruct[]", len(xyz)) but nothing works...
antocuni has quit [Ping timeout: 240 seconds]
aboudreault has joined #pypy
adamholmberg has joined #pypy
marky1991 has joined #pypy
yuyichao_ has quit [Ping timeout: 240 seconds]
<arigato> solarjoe4: it's "char[]" instead of "char *" because it has a known length. that's about the only difference between the two types in C
<arigato> yes, you should do ``z = ffi.cast("mystruct *", y)`` and then access ``z`` as an array, e.g. ``z[3].foo = 42``
aboudreault_ has quit [Quit: Ex-Chat]
<solarjoe4> ok, thanks. in the end I need an array of mystruct. the struct where pass the array into wants "mystruct *xyz". So this is just the pointer to the first one. but how is the length of the array handled?
<solarjoe4> just by the size of a single struct and the size of the buffer?
yuyichao_ has joined #pypy
<arigato> ah, well, the support for actually getting cdatas of type "mystruct[]" is a bit limited
<arigato> most of the time, it works like C in that there is no such thing as "mystruct[]", you use "mystruct *"
<arigato> the two types are quite interchangeable
<arigato> in C, "mystruct[]" is a type but objects of that type are actually systematically "mystruct *"
<arigato> in CFFI we keep types like "char[]" instead of "char *" in cases where we can be sure about the length, which is stored together with the "char *" pointer
<arigato> but there is not really a way to cast the "char[]" into a "mystruct[]" by dividing the length
<arigato> you can only cast it to "mystruct *" and then it works like a pointer OR an array of unknown length
<arigato> btw even with cdatas like "char[]", you can inspect the stored length with "len(x)" but when passing this cdata to a C function call for example you just pass the "char *"
<solarjoe4> so there is nothing like z = ffi.cast("mystruct *", y), len(x)? I do know the length from the numpy array, but is that nowhere available in the cdata?
<arigato> that's almost correct, yes. because in C you wouldn't be able to do that either. if needed you need to keep the length yourself
<arigato> now there are actually ways if you really want to
<arigato> like, I think, z = ffi.cast("mystruct[42]", y)
<arigato> or you can play around with custom allocators, ffi.new_allocator()
<solarjoe4> uh, I guess that is too complex for me at the moment :) I hardly get the basics
<arigato> right. all in all, CFFI's basic design idea is that if it exists in C then you should be able to do it in CFFI, and vice-versa
antocuni has joined #pypy
<solarjoe4> just to understand this, ffi.new(int[], 4) is of type "int[]", but in the end it is also "int*", but the "[]" means something like "length is known" ?
<arigato> yes, exactly
<arigato> length is known, so you can do len(x) and you get IndexError past that length, but if you pass that to C code then you're just passing the "int *" without the length
<solarjoe4> yes, just tried it, but len is in bytes, not in elements, right?
<arigato> no, in elements
<arigato> ffi.new("int[]", 4) returns an array of 4 ints, so 16 bytes
<solarjoe4> yes, correct. I tried, y = s2.ffi.from_buffer(x), len(y), that seems to be bytes
<arigato> right, but that's because y is "char[]", so number of bytes equal number of elements
<arigato> (it's guaranteed that the type "char" is always one byte)
<solarjoe4> oh, I guess I get it know... char[] does basically mean "array of bytes? It is not related to strings at all, right? I thought this is the adress of the first element of the buffer as string
<arigato> ah, yes, "char[]" is often used in C to mean "just some buffer"
<arigato> not necessarily printable strings
<solarjoe4> thanks a lot, this was very helpful!
<arigato> np
<arigato> ffi.from_buffer() really returns a pointer to the existing buffer, without making a copy
<arigato> so it could return a "void *"
<arigato> the fact that it returns "char[]" instead of "void *" is just to give you an extra bit of safety by also storing the maximum length
<arigato> but indeed it's often not very useful, because you need to cast it to "anothertype *", and then you loose the stored length anyway
<solarjoe4> thanks, bye
solarjoe4 has quit [Quit: Leaving]
Rhy0lite has joined #pypy
Joghurt_ has joined #pypy
xqb has quit [Remote host closed the connection]
xqb has joined #pypy
gthank is now known as gthank_away
gthank_away is now known as gthank
gthank is now known as gthank_away
gthank_away is now known as gthank
gthank is now known as gthank_away
gthank_away is now known as gthank
raynold has joined #pypy
antocuni has quit [Ping timeout: 248 seconds]
drolando has quit [Remote host closed the connection]
drolando has joined #pypy
jcea has quit [Quit: jcea]
Joghurt_ has quit [Read error: Connection reset by peer]
marky1991 has quit [Read error: Connection reset by peer]
tbodt has joined #pypy
oberstet has quit [Ping timeout: 248 seconds]
oberstet has joined #pypy
jcea has joined #pypy
commandoline has quit [Ping timeout: 248 seconds]
commandoline has joined #pypy
Rhy0lite has quit [Quit: Leaving]
Thinh has joined #pypy
chelz has quit [Remote host closed the connection]
gthank is now known as gthank_away
tbodt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tbodt has joined #pypy
tbodt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<kenaan_> cfbolz default 6a370242b86c /pypy/: merge cpyext-faster-arg-passing When using cpyext, improve the speed of passing certain objects from PyPy to C co...
tbodt has joined #pypy
xorAxAx has quit [Remote host closed the connection]
xorAxAx has joined #pypy
adamholmberg has quit [Remote host closed the connection]
adamholmberg has joined #pypy
oberstet has quit [Ping timeout: 248 seconds]
tbodt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tbodt has joined #pypy
adamholmberg has quit [Remote host closed the connection]
adamholmberg has joined #pypy
adamholmberg has quit [Ping timeout: 248 seconds]
gcbirzan_ is now known as gcbirzan
norox has quit [Remote host closed the connection]
xqb` has joined #pypy
xqb has quit [Disconnected by services]
xqb` is now known as xqb
adamholmberg has joined #pypy
norox has joined #pypy
tbodt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tbodt has joined #pypy
adamholmberg has quit [Remote host closed the connection]
adamholmberg has joined #pypy