Jump to content

C, Python, and a question


Recommended Posts

I'm writing a primitive-neighbour-finding script in Python and it's unbearably slow so I had a go at C and it's amazingly faster. At the moment the C code is completely external and uses a *.txt file generated by a Python script.

Now that I got the taste for it, can I call that C app from within Houdini? I've read that I need full version of vc8 to work with the HDK, which I don't have.

How about calling C from Python. Is that a workable option?

Link to comment
Share on other sites

for using the hdk you need just the vc-compiler which can be downloaded from the microsoft site. its included it the windows sdk.

when calling c in python or wrapping modules i would have a look at cython. if you are on windows and python 2.5 you have to go with 32bit or build it for 64bit by your own.

for general speedup of python code there is also psyco. again just for 32bit.

and if you are not in hurry you can also wait for houdini 10.5. according to the python feature list you can write c++ direct in python and it gets compiled and loaded automatically. this gives you also access to the hdk gu_detail class.

hth.

petz

Link to comment
Share on other sites

Thanks for the answer Petz. I thought my question was a bit silly at first.

I have tried psyco and it's OK but doesn't give anywhere near the performance I gained from pure C.

That new c++ feature sounds very very amazing. I can't wait for it!

Link to comment
Share on other sites

If the c app is stand-alone and takes stdin and passes to stdout in bgeo or geo format, you "could" use the Unix SOP for testing. Have a look at it's help. Note that Unix SOP works on all OS'es and not just "Unix".

Again a proper first class c++ object would be optimal as was mentioned above.

Link to comment
Share on other sites

Guest Swann

Ok, is there possibility to use different language than C++ with this unixSOP ?

EDIT: Oh wait, it just runs external program and doesn't care about language type, yes ?

Edited by SWANN
Link to comment
Share on other sites

You can use whatever you want to build the tool: python, c++, c, bash, csh, etc.

As long as your stand-alone command-line tool:

- can take geo/bgeo geometry as stdin

- output geo/bgeo geometry as stdout

See the help on the Unix SOP.

Link to comment
Share on other sites

Guest Swann

So what's the advantages of using HDK instead of UnixSOP ?

Somebody can have descent tools that can be adapted to use bgeo, and bgeo imports every attributes,groups etc. so he may prefer to not jump into HDK or just simply learn/switch to C++ and use language that he prefers.

I'm asking as person who likes Microsoft productes and C# is my language of choice. Not that I have big programming experience but I really like to avoid jumping into C++ that is messy as hell.

Link to comment
Share on other sites

Guest Swann

One advantage is definetely that you can use HDK not only in SOPs, but for SOPs I don't see why somebody should use HDK instead of UnixSOP.

Link to comment
Share on other sites

Well, HDK has the advantage of speed like its native counterparts and as well as doing anything you want. But codes can potentially be difficult to maintain from version to version depends on what you do and the library you use. UnixSOP is definitely far easier because you can use any language of your choice, as long as you can parse the geometry stream. But Unix SOP has overhead, as it is effectively a pipe instead of a native tool.

Many many years ago I've seen some long-time Houdini user using Unix SOP to do things outside of Houdini due to certain limitations in Houdini at that time. But these days on a daily production basis, most of what we do can be done in Houdini itself that I hardly see anyone break outside of Houdini to write custom codes (with the exception of some very specific needs and requirements, that is). So I guess your mileage will vary.

Unix SOP is a very useful tool when you need it. I guess I just haven't used it in years....

Link to comment
Share on other sites

Does anybody have an example of code that works with with the Unix SOP (on windows), however simple it may be. I want to understand how to get data in and out. A C# example would be welcome but any other language too, perhaps I can work my way through it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...