Newbie questions

36 views
Skip to first unread message

James King

unread,
Mar 5, 2012, 3:33:58 PM3/5/12
to shedskin-discuss
Hi,

I've been watching the Shedskin project for a while and decided to
give it a whirl last night. It's pretty cool, but I can't seem to
follow the tutorial on calling external C/C++ functions. As I
understand, I would have to first write a template for my 'stuff' (C/C+
+) module, and then fill in the blanks after shedskin generates the
cpp file?

What about in a situation where I already have C/C++ code? Or I want
to call an existing C/C++ library and use it within Shedskin?

In particular, I was wondering how one might write (now, or maybe in
future Shedskin releases..) Python code that could run as a cpython
interpreted script (and call C/C++ code via ctypes for example) and
also have that code work under shedskin when it gets compiled to C++.

Also, as a separate question -- is there a plan to ever have [some]
support for eval or exec?

Thanks for your help!
-James

Mark Dufour

unread,
Mar 8, 2012, 6:00:47 PM3/8/12
to shedskin...@googlegroups.com
hi james,

my apologies for the delayed reply.

> I've been watching the Shedskin project for a while and decided to
> give it a whirl last night. It's pretty cool, but I can't seem to
> follow the tutorial on calling external C/C++ functions. As I
> understand, I would have to first write a template for my 'stuff' (C/C+
> +) module, and then fill in the blanks after shedskin generates the
> cpp file?

yes. to be sure, I just followed the steps outlined in the
documentation, and this still seems to work. do these steps work for
you, or what kind of problem do you run into..?

> What about in a situation where I already have C/C++ code? Or I want
> to call an existing C/C++ library and use it within Shedskin?

I'm afraid this currently requires you to write a manual "bridge" in
lib/, similar as to what happens in the 're' module, for example:
lib/re.py provides just enough python code to perform type inference,
and lib/re.?pp manually calls into libpcre.

> In particular, I was wondering how one might write (now, or maybe in
> future Shedskin releases..) Python code that could run as a cpython
> interpreted script (and call C/C++ code via ctypes for example) and
> also have that code work under shedskin when it gets compiled to C++.

I have no experience with ctypes, so I can't say if it's possible to
statically determine all or most types for a program that uses it..
but if this is possible, I guess shedskin should be able to support it
(to some degree perhaps).

> Also, as a separate question -- is there a plan to ever have [some]
> support for eval or exec?

perhaps seriously restricted versions of these, but not the real
thing, since it's fundamentally impossible to determine statically
what happens when you execute some arbitrary string..

thanks for your questions!
mark.
--
http://www.youtube.com/watch?v=E6LsfnBmdnk

Pʀoмᴇтнᴇυs 0x01

unread,
Mar 8, 2012, 6:30:59 PM3/8/12
to shedskin...@googlegroups.com
Hi Mark, thanks for getting back to me!

I'm still experimenting with using python with other languages, so I didn't get a chance to test out the example for C/C++ code yet, but I guess what I would want to do later would be to write a bridge between a C/C++ library and shedskin generated code. The potential for a restricted version of eval/exec is also great to hear as well!

I wish I could contribute in some way, but I'm still in the middle of my studies and I'm not anywhere near the level of expertise needed to help on this kind of project. I appreciate your work though, and I think it's great stuff!

-James


--
You received this message because you are subscribed to the Google Groups "shedskin-discuss" group.
To post to this group, send email to shedskin...@googlegroups.com.
To unsubscribe from this group, send email to shedskin-discu...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/shedskin-discuss?hl=en.


Reply all
Reply to author
Forward
0 new messages