igormarfin / shedskin

Automatically exported from code.google.com/p/shedskin
0 stars 0 forks source link

Passing classes/instances from cpython to shedskin. #177

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What version of the product are you using? On what operating system?
Shedskin 0.9.3, Windows 7 64-bit.

Please provide any additional information below.
Hello guys.
According to the docs, you can freely pass instances of user-defined classes 
between cython and shedskin, I couldn't figure out how though, could you 
provide a simple example please?
Also, I can't compile the "simple_module.py" example, even the simple function:
def func1(x):
    return x+1
Returns "variable "x" has no type" and 'make' fails to compile.
Thank you.

Original issue reported on code.google.com by repgahr...@gmail.com on 23 Jan 2013 at 3:15

GoogleCodeExporter commented 8 years ago
An example on passing and calling cython functions from shedskin would be 
useful also (if possible).

Original comment by repgahr...@gmail.com on 23 Jan 2013 at 4:21

GoogleCodeExporter commented 8 years ago
Forget that part about the example not compiling, I just noticed that you have 
to pass types when calling the function in the shedskin file, however, how can 
you pass a "class" type or a "function" type?

Original comment by repgahr...@gmail.com on 23 Jan 2013 at 3:26

GoogleCodeExporter commented 8 years ago
thanks for asking. I'm afraid you can't pass classes or functions right now. 
there are a few other limitations when generating an extension module. these 
are described in the 'generating an extension module' section of the 
documentation. let me know if you run into any other problems!

Original comment by mark.duf...@gmail.com on 23 Jan 2013 at 7:53

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Thank you for your reply. I don't know if this is the right place to ask, so 
sorry if it isn't.
I saw the examples using pygame (circle and pygasus(although pygasus doesn't 
compile on the latest version)) and they are using the cpython side of the 
program to interact with pygame and the Shedskin part for processing-intensive 
stuff. That works a treat, but sometimes you want to actually run a function on 
the cpython side according to what happens on the Shedskin side, I have a few 
ideas on how this could be done, but I don't know if it's a good approach or 
could be more efficient, anyway my best idea is:

-Pass a list containing an integer and parameters from the Shedskin side to the 
cpython side
-On the cpython side you have a list of functions, and the integer represents 
the index of the function you want to run, so you have something like:
myfuncs[integerfromshedskin](argumentsfromshedskin), it should work as long as 
the arguments types are possible in Shedskin.

I don't know if it's a good way of doing that though. And I think you'll need a 
loop on the cpython side to keep checking for values from the Shedskin side.

Anyway, Shedskin is a very good project and it's a pity it doesn't get more 
attention. Congratulations for this amazing software. When I first compiled the 
circle example i was very impressed. It runs like 1fps on cpython and 45+fps 
after compiling some parts of it in Shedskin but still using cpython for the 
"light" part. So congratulations for achieving such a good product.
Thank you.

Original comment by repgahr...@gmail.com on 23 Jan 2013 at 11:12

GoogleCodeExporter commented 8 years ago
the discussion group is probably a better place to ask, but here is fine too ^^

you'll often have to puzzle a bit about how to best use shedskin in a given 
situation. would it be possible to share your code, so perhaps I could have a 
look?

yes it's especially a pity that I'm not getting much help at the moment on the 
development side, because that could really speed up development (I'm not 
spending huge amounts of time on it anymore).

Original comment by mark.duf...@gmail.com on 26 Jan 2013 at 1:32