dynamic-language-runtime

IronPython import performance with compiled code

百般思念 提交于 2019-12-06 15:02:21
I am doing some experiments with IronPython 2.6.1 and the clr.CompileModules function to compile my large scripts into assemblies. Testing has shown good cold start performance performance improvements but in some cases importing the compiled module is actually slower than executing a large string that represents my code in some cases. My question is, if i use something like scope.Engine.Execute(string.Format("from {0} import {0}", theModule), scope); or the ImportModule function, even though I get a new ScriptSCope back does the DLR cache the imports made in other ScriptScopes? So if module 1

C# application works much slower using compiled IronPython standard library

元气小坏坏 提交于 2019-12-06 13:52:49
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 distutils import dir_util import ftplib import os import tempfile import zipfile"); source.Execute(scope);

DLR return type

橙三吉。 提交于 2019-12-05 22:37:46
问题 I need some DLR help. I am implementing an IDynamicMetaObjectProvider and DynamicMetaObject but I am having some issues getting the expected return type. I am overiding BindInvokeMember in the metaobject, I can see all the args types but no return type. Anyone know how I get to it if possible? I know the return type is dynamic but what if the thing you are invoking is dependent on a return type. I don't know which action to perform in the DynamicMetaObject unless I know the return type the

How do I implement intellisense support for a custom DLR language in VS2008?

∥☆過路亽.° 提交于 2019-12-05 18:19:54
I have just started writing my first language for the .NET DLR. I would like to know if it is possible to extend Visual Studio 2008 IntelliSense to handle the syntax of a custom DLR language? EDIT: I have decided to bypass VS2008 and target VS2010 instead. See accepted answer for more information. Visual Studio's primary extensibility method for supporting new languages is through Language Services in a VSPackage . Visual Studio 2010 has radically improved the ability to support a new language, but if target your extension to it you will not be able to use it in older versions. If you write a

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

江枫思渺然 提交于 2019-12-05 12:27:13
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 class library project to be self contained and not depend on a complete installation of IronPython. The

DLR and Javascript interpretation in c# 4?

社会主义新天地 提交于 2019-12-05 12:10:26
I want to execute a javascript code from c# using DLR. So I wrote a simple code using c# and Jint : var script = @" function show( ) { return parseInt('123asd'); //in js it's 123 }; return show();"; var result = new JintEngine().Run(script); Console.WriteLine(result); parseInt('123asd') in javascript is : 123 But the result I get is : Maybe I don't see the whole picture, but if a programmer on the other side of the world sends me his script file, I (and him) expect the result to be consistent! If I was mistaken, in what scenario would I use running other code on .Net? (I will have to be very

How to Implement the Ternary Operator in the DLR

淺唱寂寞╮ 提交于 2019-12-05 11:44:44
I am implementing a language interpreter in C# using the DLR, and I'm having some troubles with the ternary operator. At this point, I have basic function declarations/calls implemented, like so: F := (x) -> x + 1 F(1) # returns 2 I've not had a problem with a function body being a sequence of expressions -- the value of the last expression is always returned, and I've made sure all cases in the interpreter return at least something as a side effect. I'm now trying to implement the ternary operator (? :). The Expression tree I'm rendering looks like this: work = Expression.IfThenElse(

DynamicObject implicit casting

自闭症网瘾萝莉.ら 提交于 2019-12-05 10:38:59
I have a subclass of DynamicObject and I would like to implement implicit casting for primitive types similarly as DO's explicit casting method TryConvert; that is, without writing multiple implicit operator [type] functions. Usage: dynamic myDynamicObject = new MyDynamicObject("1"); int sum = 1 + myDynamicObject; // instead of int i = 1 + (int)myDynamicObject; Is that possible and if so, how? There are several things going on here. First, you are performing a binary operation. So, you need to override TryBinaryOperation method as well. It will be called first, before conversion. Then from the

Ambigious reference for ExtensionAttribute when using Iron Python in Asp.Net

妖精的绣舞 提交于 2019-12-05 08:22:21
问题 I get the following error when starting an Asp.Net site that uses an assembly that in turn makes use of the dlr and Iron Python for scripting. BC30560: 'ExtensionAttribute' is ambiguous in the namespace 'System.Runtime.CompilerServices'. The issue seems to be known and there's a workaround in the issue tracker. However it says that they... ... hope that this workaround will not be necessary in the next release. The latest release (the one that I'm using) is a later release than the one

NancyFX: How do I check if query-string / form values have been correctly passed to my handler?

末鹿安然 提交于 2019-12-05 04:24:52
Nancy passes my query-string and form values to my handlers via a dynamic variable. The example below shows form values being passed in to a POST handler via the Nancy request e.g. Request.Form.xxx . Handler Post["/"] = _ => { var userId = (string) Request.Form.userid; if (userId.IsEmpty()) return HttpStatusCode.UnprocessableEntity; return HttpStatusCode.OK; }; You can see that I am casting the userid to a string and then using a string extension method to check if the value is null or empty string (equivalent to string.IsNullOrEmpty() ). What I would prefer is to to have the extension method