[IronPython] Did you find any purpose to compile IronPython code to DLL using pyc.py

Max Belugin mbelugin at gmail.com
Fri May 4 14:43:50 CEST 2007


Can you get me some advice about decreasing startup time?

Should I use one engine with multiple modules or multiple engines?

What sre perspectives? Will DLR solve this prproblem?

This is source of my loader (I am creating one engine instace for each script):

using FarManager;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using IronPython.Hosting;
using IronPython.Modules;
public class IronPythonLoader : BasePlugin
{
	protected string PluginFile(string name)
	{
       	FileInfo fi=new FileInfo(Assembly.GetExecutingAssembly().Location);
       	return fi.Directory.Parent.FullName+"\\"+name;
    }
    protected void LoadScript(string fileName)
    {
		PythonEngine engine = new PythonEngine();
		engine.AddToPath(Path.GetDirectoryName(fileName));
		engine.Import("site");		
		ClrModule clr =  (ClrModule)engine.Import("clr");

		
		EngineModule engineModule = engine.CreateModule("__main__", false);
        engine.DefaultModule = engineModule;

		clr.AddReferenceByPartialName("FarNetIntf");
		engine.Import("FarManager");
		engine.Globals["far"] = Far;
		engine.ExecuteFile(fileName);
    }
	override public void Connect()
	{
		string scriptsFolder = PluginFile("Scripts");
		foreach(FileInfo file in new DirectoryInfo(scriptsFolder).GetFiles())
			LoadScript(file.FullName);
	}
}


On 5/4/07, Michael Foord <fuzzyman at voidspace.org.uk> wrote:
> Max Belugin wrote:
> > Thank you Michael, can you show me example of using that precomiled
> > code? How to use those dlls from python or C#
> >
>  From Python you just use the normal import statements. You can verify
> this by deleting the source files after compilation.
>
> You can't use them directly from C# - but must write stub classes that
> call into the IronPython engine.
>
> Michael
>
> > On 5/4/07, Michael Foord <fuzzyman at voidspace.org.uk> wrote:
> >
> >> We experimented with precompiling all of our code to see if it would
> >> help with startup time.
> >>
>
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>


-- 
Max Belugin, http://belugin.info , ICQ:9406811



More information about the Ironpython-users mailing list