iivari at mokelainen.com
Fri Sep 3 08:33:20 CEST 2010
Thank you! That asnwered to all of my questions - after loading the
executing assembly into the python runtime I was able to run "from
namespace import *" and that did the job.
About the interop: wow that's really good. Never thought DLR team could
make it that fast.
On 3.9.2010 4:23, Dino Viehland wrote:
> To expose a whole namespace the simplest way is probably to call
> scriptRuntime.LoadAssembly(some_assembly); All of the public types
> will then be available for importing from IronPython. That means they
> won't all be available at the top-level. If that's not ok you could
> use reflection and call DynamicHelpers.GetPythonTypeFromType(...) and
> inject all the types you want.
> As for interop the performance should be fine. When using dynamic
> from C# the overhead should basically be similar to the overhead of
> calling a function within Python. And for Python calling into C# the
> overhead is the same as any Python code calling into any of the
> runtime -- in other words pretty darn fast. For a simple function
> call to a Python function last I measured I believe it was around 40
> instructions on x86 to perform the call.
> For example on my laptop this runs in about 1/3 of a second and
> performs 10 million function calls:
> import time
> def f():
> def g(): pass
> for i in xrange(10000000):
> s = time.clock()
> e = time.clock()
> print e -- s
> So what probably matters a lot more is what the function is doing.
> *From:* users-bounces at lists.ironpython.com
> [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Iivari
> *Sent:* Thursday, September 02, 2010 9:29 AM
> *To:* users at lists.ironpython.com
> *Subject:* [IronPython] Integration
> Salut, fellow coders!
> I have an application where i need some live coding to debug and use
> it. I've been coding in C# for ages now.
> I looked into different languages, and found python. And obviously
> fell in love.
> Now i have a home-made interactive python console with my application.
> I implemented suggestions with dir() and so on.
> The problem im facing is that I need to integrate whole application
> with the console now. I know I can expose types and variables thru
> scope.SetVariable but what I need is to expose a whole /namespace/ to
> the scope.
> Any help would be appreciated.
> P.S. How fast is interop between python and C#? Would it be ok to have
> a python function as dynamic in C# and calling it about 250 times a
> Iivari Mokelainen
> Users mailing list
> Users at lists.ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users