cfbolz changed the topic of #pypy to: PyPy, the flexible snake (IRC logs: https://botbot.me/freenode/pypy/ ) | use cffi for calling C | the secret reason for us trying to get PyPy users: to test the JIT well enough that we're somewhat confident about it
<fijal>
mattip_: the 2 version completely removed Unicode internally
<fijal>
I do not know why the 3 one didn't, maybe for reasons like "let's run it"
speeder39 has joined #pypy
hotpot33 has joined #pypy
exarkun has quit [Ping timeout: 260 seconds]
user24 has joined #pypy
exarkun has joined #pypy
dddddd has joined #pypy
marself has joined #pypy
twn has joined #pypy
<twn>
Hi I have a question about using rffi. Say I have a C function prototype like this: void mock_print(long* data, unsigned long len);
<twn>
How do I hook that up using rffi.llexternal?
<twn>
I feel like it should be something roughly like this: mock_print = rffi.llexternal("mock_print", [lltype.Array(lltype.Signed), lltype.Unsigned], lltype.Void, compilation_info=info)
<twn>
That isn't working (and may be deranged), but I'm not sure how to call this
<twn>
As a secondary question, how would this then be called? I.e. I'd like to do something like this: mock_print([1, 2, 3], 3) but I'm not sure if that conversions are done automatically
<twn>
Thanks a lot in advance for any help!
<cfbolz>
mattip_: yes, imo unicode_w should go away, only bytes_w, text_w and utf8_w should be left
<fijal>
twn: you definitely want lltype.Ptr
<fijal>
but also lltype.Array is an RPython array, not c level something*
<fijal>
so you want rffi.CArrayPtr(lltype.Signed)
<fijal>
the conversions are not automatically, partly because of the lifetime considerations
<fijal>
so you would need to create your own lltype.malloc(rffi.CArray(lltype.Signed), 3, flavor='raw')
<fijal>
and then lltype.free it
<fijal>
there might be some helpers though
exarkun has quit [Ping timeout: 240 seconds]
exarkun has joined #pypy
<twn>
great thanks just tested it out and it works perfectly! thanks for clearing up the confusion!
<fijal>
I'm sorry it's not that well documented
user24 has quit [Quit: Leaving]
antocuni has joined #pypy
mcyprian has joined #pypy
<twn>
no worries! i'm having a little fun twisting my brain around into understanding how things hang together with pypy and rpython so a little struggle isn't totally unwelcome :)
<twn>
besides maybe once i sort things out and have the confusion fresh in my mind i can make some improvements to documentation (no promises!)
speeder39 has quit [Quit: Connection closed for inactivity]
inhahe_ has quit []
inhahe has joined #pypy
<twn>
Hi I have another question. Am I able to use descriptors in rpython? I have a custom __getitem__ defined, but it throws an error like "[translation:ERROR] AttributeError: 'FrozenDesc' object has no attribute 'getuniqueclassdef' "
adamholmberg has quit [Read error: No route to host]
adamholmberg has joined #pypy
<twn>
Hello I was wondering if anyone wants to let me pick their brain a bit. I could also take this to the mailing list, but I figure I would ask here first. I started working on this issue last week: https://bitbucket.org/pypy/pypy/issues/1901 The point as I understand it is to change the code in rpython/rlib/rrandom.py to use compiled binary code to see if it speeds things up. I decided to try it out mainly to see if I could learn a bit more about
<twn>
pypy and as a by-product maybe doing something useful. So what I've done so far is to first take the code in numpy and adapt it to using cffi as an installable module to pass the tests. Then I changed that to use rffi and compiled a small binary in rpython which is also passing the tests. Then I moved that code into the interpreter itself and got it to build. The problem at this point is that I realized that I am using llexternal to call code
<twn>
that I feel should just be directly compiled into the interpreter instead of my current method which runs into issues. Anyway is this to sort of thing to bug people on irc about or the mailing list or the issue tracker or ... ? In any case, thanks a lot for any help and advice!
<twn>
btw i haven
<twn>
btw i haven't updated that issue i linked with the latest stuff i've done. i thought i'd ask here before continuing to write stuff there in case other areas are more trafficed
altendky has joined #pypy
<cfbolz>
twn: asking here is the right approach
<cfbolz>
I'll try to take a look at your code soon, maybe will manage tonight
<twn>
oh great thanks a lot. in that case i think i will update that issue with a clearer explanation of what i've done so far and the final problems i've run into. at least so that my issue comments are up to date with my code
<cfbolz>
Cool
<cfbolz>
twn: llexternal is the right approach imo
<twn>
oh okay cool. so the problem i run into is basically this. i can compile the interpreter, but when i actually try to call the methods themselves the c functions are not being found. this is why i thought it would be best philosophically the actually have the functions compiled in directly. it feels like llexternal is better suited to maybe an external c library. of course this could all just be confusion and i am presumably just using it wrong
<twn>
anyway maybe don't worry now. i'll explain the issues i'm having more clearly so that it makes more sense in the issue itself
<twn>
thanks for the help
lritter_ has joined #pypy
mattip has joined #pypy
<cfbolz>
twn: so it's some kind of linking problem?
exarkun has quit [Read error: Connection reset by peer]
<twn>
yeah seems like it. i assume it's just that i'm using it wrong though
exarkun has joined #pypy
mattip has quit [Ping timeout: 240 seconds]
tayfun26 has quit [Quit: tayfun26]
slacky has joined #pypy
antocuni has joined #pypy
mattip has joined #pypy
<cfbolz>
twn: that stuff can be tricky to figure out
Guest87736 is now known as phlebas
dash has quit [Read error: Connection reset by peer]
yuvipanda has quit [Remote host closed the connection]
abvi[m] has quit [Remote host closed the connection]
bendlas has quit [Remote host closed the connection]
agates has quit [Remote host closed the connection]
<twn>
cfbolz: i updated the issue here: https://bitbucket.org/pypy/pypy/issues/1901 the final comment is up to date. i hopefully added in enough error messages and detail so you'll be able to see what my problem is without needing to recompile everything
<twn>
and don't worry about a super fast response. there isn't any rush since i'll probably be away from the comp for the rest of the evening. thanks a lot again for taking a look at things.
antocuni has quit [Ping timeout: 260 seconds]
antocuni has joined #pypy
yuvipanda has joined #pypy
raynold has joined #pypy
Gonsor has joined #pypy
antocuni has quit [Ping timeout: 256 seconds]
antocuni has joined #pypy
antocuni has quit [Ping timeout: 256 seconds]
jamesaxl has quit [Ping timeout: 268 seconds]
jamesaxl has joined #pypy
dash has joined #pypy
bendlas has joined #pypy
agates has joined #pypy
abvi[m] has joined #pypy
marky1991 has joined #pypy
marky1991 has quit [Remote host closed the connection]
marky1991 has joined #pypy
lesshaste has joined #pypy
nunatak has joined #pypy
marky1991 has quit [Read error: Connection reset by peer]