ironpython

IronPython vs Python speed with numpy

◇◆丶佛笑我妖孽 提交于 2019-12-23 01:05:08
问题 I have some Python source code that manipulates lists of lists of numbers (say about 10,000 floating point numbers) and does various calculations on these numbers, including a lot of numpy.linalg.norm for example. Run time had not been an issue until we recently started using this code from a C# UI (running this Python code from C# via IronPython). I extracted a set of function calls (doing things as described in the 1st paragraph) and found that this code takes about 4x longer to run in

Hosted IronPython: import files which contain custom functions

馋奶兔 提交于 2019-12-22 23:24:18
问题 Situation Hosted IronPython allows developers to set parameters into script. Every time when a IPy engine object is created, I set such a parameter (ParamName), but when I try to import python module, in which my custom parameter is used, I get an exception with message "global name 'ParamName' is not defined". Code sample class PythonScriptingEngine { private ScriptEngine pyEngine; private ScriptScope pyScope; public PythonScriptingEngine() { pyEngine = Python.CreateEngine(); pyScope =

Missing lxml module in python?

↘锁芯ラ 提交于 2019-12-22 17:58:36
问题 I want o use Python-docx library to process word files. A docx.py references lxml, as i assume from from lxml import etree When i start the script, i get error: No module named lxml Is this a standard library? Why is not it referenced properly then? IronPython 2.7 RC1. 回答1: You need to install lxml which is not part of the stdlib. I don't know if it will work with IronPython though. Update : Seems like it might be non-trivial to get lxml working with IronPython. See this question: How to get

How to use a specific interface on a C# object in IronPython

浪尽此生 提交于 2019-12-22 17:45:56
问题 I have a C# class that implements 2 IEnumerable interfaces. How can I access either interface from IronPython? My class: public class MyClass : IEnumerable<TypeA>, IEnumerable<TypeB> { IEnumerator<TypeA> IEnumerable<TypeA>.GetEnumerator() { return _lstTypeA.GetEnumerator(); } IEnumerator<TypeB> IEnumerable<TypeB>.GetEnumerator() { return _lstTypeB.GetEnumerator(); } } I tried the following in Python, but although it runs without errors it does not return any elements from the IEnumerable

T4 with languages other than C# and VB

喜欢而已 提交于 2019-12-22 12:23:33
问题 Is it posible to write T4 templates in other .NET languages? In particular I'm interested in F# and IronPython. 回答1: The doc stipulates that only VB and C# are supported: T4 Template Directive, see the language attribute. 回答2: I was complaining about this on twitter some time ago. It seems reasonable - afterall, T4 is just using CodeDOM provider! Anyway, Michael Hutchinson (from Mono team) suggested using the implementation in Mono, which should be extensible. I didn't look into that further,

C# application works much slower using compiled IronPython standard library

て烟熏妆下的殇ゞ 提交于 2019-12-22 11:22:43
问题 When I load modules from standard library as source .py files in this application, elapsed time after end equals approximately 4 seconds: Stopwatch watch = Stopwatch.StartNew(); ScriptEngine engine = Python.CreateEngine(); ScriptScope scope = engine.CreateScope(); ICollection<string> paths = engine.GetSearchPaths(); paths.Add(@"C:\Users\Montgomery1944\Documents\Libs\IronPython-2.7.1\Lib"); engine.SetSearchPaths(paths); ScriptSource source = engine.CreateScriptSourceFromString( @"from

How namespace and assembly names work for IronPython types?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 10:34:32
问题 Have an IronPython package named "Entities". That package contains an "Entity.py" file that defines a "Customer" class and an "Address" class. If I run this program: customer = Customer() print customer.GetType().AssemblyQualifiedName address = Address() print address.GetType().AssemblyQualifiedName I get this output: IronPython.NewTypes.System.Object_1$1, Snippets.scripting, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null IronPython.NewTypes.System.Object_1$1, Snippets.scripting,

Can't import numpy into embedded ironpython engine

三世轮回 提交于 2019-12-22 09:55:28
问题 From an ipy console I can import ironclad import numpy with no problem. However when I try the same imports with an embedded interpreter the numpy import fails. My Python engines is set up like this: public PyEngine() { //Frames option needed to use sys.__getframe //used in Numpy and others. Dictionary<string, object> opts = new Dictionary<string, object>(); opts["Frames"] = ScriptingRuntimeHelpers.True; engine = Python.CreateEngine(opts); scope = engine.CreateScope(); runtime = engine

How to refer self-contained C# class library project with IronPython inside (Visual Studio 2010)

故事扮演 提交于 2019-12-22 09:17:35
问题 This question is kind of lengthy but I try to provide you with the details that I think is necessary to find the answer. I have a C# WPF solution (.Net 4) consisting of a main project, building a WPF windows app, which depends on a few class library projects residing in the same Visual Studio 2010 solution. One of the class library projects encapsulates some previously developed python code that I want to make use of through IronPython and Microsoft Dynamic Language Runtime. I would like the

IronPython + Emacs?

大憨熊 提交于 2019-12-22 08:55:38
问题 I've decided to get into IronPython, as I work pretty much exclusively in .NET, but need something a little less stuffy than C# for mocking up quick stuff. Python has been fine for small things, throwaway tests, that sort of stuff, but it's to the point that I need to be able to get to some of our .NET code. Despite my complete revulsion, I've been using emacs for Python editing, and I'd like to use it for IronPython as well, assuming it's possible. Google has not been forthcoming with