[IronPython] Code generation questions

Masters, Christopher christopher.masters at credit-suisse.com
Fri Feb 29 07:22:22 PST 2008


Hi

Sorry if this is documented somewhere but can anyone help me with the following? 

If I (in 1.1.1) Execute() a string with code that defines some classes/defs methods, how long does the code generated last? For instance if I had the following script:

class Foo:
	def __init__(self):
		# ...
	def DoWork(self):
		print "Doing work"

def Run():
	Foo().DoWork()

And I hosted a runtime and executed this via:

using (PythonEngine pe = new PythonEngine())
{
	IronPython.Runtime.Calls.Function0 run;
	pe.Execute(_pack[_pack.Properties["EntryPoint"]]);
	run = (IronPython.Runtime.Calls.Function0)pe.Globals["Run"];
	run.Call();
}

Is Run emitted as a DynamicMethod? What happens to Foo? Is it a generated as a CLR type? In which case does it hang around forever?

What if I stored the Function0 reference and executed it later (after the PythonEngine is disposed)? Does the Foo type that Run instantiates still exist?

Does anything related to this change in 2.0?

Thanks

Chris

==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer: 

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==============================================================================



More information about the Users mailing list