Re: [IronPython] Reflection.Emit from IronPython: What is the equivalent of typeof() in C# ?

2009-08-06 Thread Shri Borde
You can also just use the type like "System.String" to avoid having to create 
an instance of the type.

>>> import System
>>> import clr
>>> clr.GetClrType(System.String)


-Original Message-
From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Dave Fugate
Sent: Thursday, August 06, 2009 2:07 PM
To: rob...@smallshire.org.uk; Discussion of IronPython; 'Michael Foord'
Subject: Re: [IronPython] Reflection.Emit from IronPython: What is the 
equivalent of typeof() in C# ?

Try:
clr.GetClrType(type(''))


David Fugate
Microsoft - IronPython
http://knowbody.livejournal.com

-Original Message-
From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Robert Smallshire
Sent: Thursday, August 06, 2009 1:53 PM
To: 'Michael Foord'; 'Discussion of IronPython'
Subject: Re: [IronPython] Reflection.Emit from IronPython: What is the 
equivalent of typeof() in C# ?

Hi Michael,

I'm afraid not:

>>> clr.GetClrType('')
TypeError: expected Type, got str

My hopes were momentarily raised when I discovered that your otherwise very
comprehensive book mentions typeof in the index (page 398) - but then I
found that you only use it from C#.

Cheers,

Rob

>
> clr.GetClrType('') ? (on an instance of a string)
>
> Michael
>
> Robert Smallshire wrote:
> > Hello,
> >
> > I'm attempting to drive the Reflection.Emit API from
> IronPython. In C#
> > typical Reflection.Emit use makes use typeof(...) facility
> in C#, to
> > enable the determination of types without needing an
> instance of that
> > type.
> >
> > For example, to create an array of .NET CTS Strings in IL
> from C# one
> > might
> > do:
> >
> > generator.Emit(OpCodes.Newarr, typeof(string));
> >
> > where the second argument to Emit is the element type of the array.
> >
> > I've tried various alternatives from IronPython, including
> >
> > generator.Emit(OpCodes.Newarr, System.Type.GetType('System.String'))
> > generator.Emit(OpCodes.Newarr, str().GetType())
> > generator.Emit(OpCodes.Newarr, System.String().GetType())
> > generator.Emit(OpCodes.Newarr, clr.GetClrType(System.String))
> >
> > however, all of these result in RuntimeType[] rather than
> String[] in
> > the generated CIL.
> >
> > How do I get typeof(System.String) from IronPython?
> >
> > Rob
> >
> > Robert Smallshire
> > rob...@smallshire.org.uk
> > http://smallshire.org.uk/
> > Currently in Norway (UTC +2 hours)
> >
> > ___
> > Users mailing list
> > Users@lists.ironpython.com
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >
>
>
> --
> http://www.ironpythoninaction.com/
> http://www.voidspace.org.uk/blog
>
>

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Reflection.Emit from IronPython: What is the equivalent of typeof() in C# ?

2009-08-06 Thread Dave Fugate
Try:
clr.GetClrType(type(''))


David Fugate
Microsoft - IronPython
http://knowbody.livejournal.com

-Original Message-
From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Robert Smallshire
Sent: Thursday, August 06, 2009 1:53 PM
To: 'Michael Foord'; 'Discussion of IronPython'
Subject: Re: [IronPython] Reflection.Emit from IronPython: What is the 
equivalent of typeof() in C# ?

Hi Michael,

I'm afraid not:

>>> clr.GetClrType('')
TypeError: expected Type, got str

My hopes were momentarily raised when I discovered that your otherwise very
comprehensive book mentions typeof in the index (page 398) - but then I
found that you only use it from C#.

Cheers,

Rob

>
> clr.GetClrType('') ? (on an instance of a string)
>
> Michael
>
> Robert Smallshire wrote:
> > Hello,
> >
> > I'm attempting to drive the Reflection.Emit API from
> IronPython. In C#
> > typical Reflection.Emit use makes use typeof(...) facility
> in C#, to
> > enable the determination of types without needing an
> instance of that
> > type.
> >
> > For example, to create an array of .NET CTS Strings in IL
> from C# one
> > might
> > do:
> >
> > generator.Emit(OpCodes.Newarr, typeof(string));
> >
> > where the second argument to Emit is the element type of the array.
> >
> > I've tried various alternatives from IronPython, including
> >
> > generator.Emit(OpCodes.Newarr, System.Type.GetType('System.String'))
> > generator.Emit(OpCodes.Newarr, str().GetType())
> > generator.Emit(OpCodes.Newarr, System.String().GetType())
> > generator.Emit(OpCodes.Newarr, clr.GetClrType(System.String))
> >
> > however, all of these result in RuntimeType[] rather than
> String[] in
> > the generated CIL.
> >
> > How do I get typeof(System.String) from IronPython?
> >
> > Rob
> >
> > Robert Smallshire
> > rob...@smallshire.org.uk
> > http://smallshire.org.uk/
> > Currently in Norway (UTC +2 hours)
> >
> > ___
> > Users mailing list
> > Users@lists.ironpython.com
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >
>
>
> --
> http://www.ironpythoninaction.com/
> http://www.voidspace.org.uk/blog
>
>

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Reflection.Emit from IronPython: What is the equivalent of typeof() in C# ?

2009-08-06 Thread Robert Smallshire
Hi Michael,

I'm afraid not:

>>> clr.GetClrType('')
TypeError: expected Type, got str

My hopes were momentarily raised when I discovered that your otherwise very
comprehensive book mentions typeof in the index (page 398) - but then I
found that you only use it from C#. 

Cheers,

Rob

>
> clr.GetClrType('') ? (on an instance of a string)
> 
> Michael
> 
> Robert Smallshire wrote:
> > Hello,
> >
> > I'm attempting to drive the Reflection.Emit API from 
> IronPython. In C# 
> > typical Reflection.Emit use makes use typeof(...) facility 
> in C#, to 
> > enable the determination of types without needing an 
> instance of that 
> > type.
> >
> > For example, to create an array of .NET CTS Strings in IL 
> from C# one 
> > might
> > do:
> >
> > generator.Emit(OpCodes.Newarr, typeof(string));
> >
> > where the second argument to Emit is the element type of the array.
> >
> > I've tried various alternatives from IronPython, including
> >
> > generator.Emit(OpCodes.Newarr, System.Type.GetType('System.String'))
> > generator.Emit(OpCodes.Newarr, str().GetType()) 
> > generator.Emit(OpCodes.Newarr, System.String().GetType()) 
> > generator.Emit(OpCodes.Newarr, clr.GetClrType(System.String))
> >
> > however, all of these result in RuntimeType[] rather than 
> String[] in 
> > the generated CIL.
> >
> > How do I get typeof(System.String) from IronPython?
> >
> > Rob
> >
> > Robert Smallshire
> > rob...@smallshire.org.uk
> > http://smallshire.org.uk/
> > Currently in Norway (UTC +2 hours)
> >
> > ___
> > Users mailing list
> > Users@lists.ironpython.com 
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >   
> 
> 
> -- 
> http://www.ironpythoninaction.com/
> http://www.voidspace.org.uk/blog
> 
> 

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Reflection.Emit from IronPython: What is the equivalent of typeof() in C# ?

2009-08-06 Thread Michael Foord

clr.GetClrType('') ? (on an instance of a string)

Michael

Robert Smallshire wrote:

Hello,

I'm attempting to drive the Reflection.Emit API from IronPython. In C#
typical Reflection.Emit use makes use typeof(...) facility in C#, to enable
the determination of types without needing an instance of that type.

For example, to create an array of .NET CTS Strings in IL from C# one might
do:

generator.Emit(OpCodes.Newarr, typeof(string));

where the second argument to Emit is the element type of the array.

I've tried various alternatives from IronPython, including

generator.Emit(OpCodes.Newarr, System.Type.GetType('System.String'))
generator.Emit(OpCodes.Newarr, str().GetType())
generator.Emit(OpCodes.Newarr, System.String().GetType())
generator.Emit(OpCodes.Newarr, clr.GetClrType(System.String))

however, all of these result in RuntimeType[] rather than String[] in the
generated CIL.

How do I get typeof(System.String) from IronPython?

Rob

Robert Smallshire
rob...@smallshire.org.uk
http://smallshire.org.uk/
Currently in Norway (UTC +2 hours) 


___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
  



--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog


___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] Reflection.Emit from IronPython: What is the equivalent of typeof() in C# ?

2009-08-06 Thread Robert Smallshire
Hello,

I'm attempting to drive the Reflection.Emit API from IronPython. In C#
typical Reflection.Emit use makes use typeof(...) facility in C#, to enable
the determination of types without needing an instance of that type.

For example, to create an array of .NET CTS Strings in IL from C# one might
do:

generator.Emit(OpCodes.Newarr, typeof(string));

where the second argument to Emit is the element type of the array.

I've tried various alternatives from IronPython, including

generator.Emit(OpCodes.Newarr, System.Type.GetType('System.String'))
generator.Emit(OpCodes.Newarr, str().GetType())
generator.Emit(OpCodes.Newarr, System.String().GetType())
generator.Emit(OpCodes.Newarr, clr.GetClrType(System.String))

however, all of these result in RuntimeType[] rather than String[] in the
generated CIL.

How do I get typeof(System.String) from IronPython?

Rob

Robert Smallshire
rob...@smallshire.org.uk
http://smallshire.org.uk/
Currently in Norway (UTC +2 hours) 

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Accessing scope variables

2009-08-06 Thread Dino Viehland
The only way I can think of doing this today would be to use our Parser
And PythonWalker classes to parse the func def and then walk it and look
for NameExpressions.

You'd also need to look for GlobalStatement's, AssignmentStatement,
and AugmentedAssignmentStatement to know if it was a global or not.


OTOH if we fixed this bug (which you can vote on):
http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=15398

you could walk the function objects, get their func_code, and then
look at co_names:

x = 42
def f():
print x
y = 42

c = f.func_code
c.co_varnames
('y',)
c.co_names
('x',)

Which looks like it has the global names which would be resolved against
your scope.  I've slowly been fixing more and more of function code but
haven't gotten to this one yet :(


> -Original Message-
> From: users-boun...@lists.ironpython.com [mailto:users-
> boun...@lists.ironpython.com] On Behalf Of Sree Pillai
> Sent: Thursday, August 06, 2009 11:57 AM
> To: users@lists.ironpython.com
> Subject: [IronPython] Accessing scope variables
>
> Hello,
>
> We are hosting IronPython in our Windows forms-based application to
> allow our customers to write scripts. We allow customers to use our own
> variables within the script.
>
> public class Variable
> {
>  string Name;
>  int Value;
>  ..
> }
>
> ..
> Variable v1 = new Variable("Length", 10);  // Create a variable with
> Name=Length and Value=10
> vars.Add(v1);
> Variable v2 = new Variable("Width", 10);
> vars.Add(v1);
> vars.Add(v2);
>
>
> We set custom variables in scriptScope like this.
>
> ..
> foreach (IVariable aVariable in vars)
> {
> scriptScope.SetVariable(aVariable.Name, aVariable);
> }
> ..
>
> With this, user can write a function like this
>
> def CalcArea() :
> return Length * Width
>
>
> In our application, we are dealing with hundreds of variables and
> functions. As the user deletes or modifies a Variable (here Length and
> Width), they would like to know where the variables are used. In this
> example, the variable Length and Width are used in CalcArea function. I
> can't find a way to identify the list of custom variables used within a
> function using the API.
>
> Any suggestions? Thanks a lot.
>
> Sree
> ___
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] Accessing scope variables

2009-08-06 Thread Sree Pillai
Hello,

We are hosting IronPython in our Windows forms-based application to allow our 
customers to write scripts. We allow customers to use our own variables within 
the script.

public class Variable
{
 string Name;
 int Value;
 ..
}

..
Variable v1 = new Variable("Length", 10);  // Create a variable with 
Name=Length and Value=10
vars.Add(v1);
Variable v2 = new Variable("Width", 10); 
vars.Add(v1);
vars.Add(v2);


We set custom variables in scriptScope like this.
   
..
foreach (IVariable aVariable in vars)
{
scriptScope.SetVariable(aVariable.Name, aVariable);
}
..

With this, user can write a function like this

def CalcArea() :
return Length * Width


In our application, we are dealing with hundreds of variables and functions. As 
the user deletes or modifies a Variable (here Length and Width), they would 
like to know where the variables are used. In this example, the variable Length 
and Width are used in CalcArea function. I can't find a way to identify the 
list of custom variables used within a function using the API.

Any suggestions? Thanks a lot.

Sree
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] IronPython 2.6 CodePlex Source Update

2009-08-06 Thread merllab
This is an automated email letting you know that sources 
have recently been pushed out.  You can download these newer 
sources directly from 
http://ironpython.codeplex.com/SourceControl/changeset/view/57787.

MODIFIED SOURCES
$/IronPython/IronPython_Main/Src/Tests/interop/net/type/test_clrtype.py
$/IronPython/IronPython_Main/Src/Tests/Modes/ConsoleFlags.ps1
$/IronPython/IronPython_Main/Src/Tests/regressions.py
$/IronPython/IronPython_Main/Src/Tests/test_sys.py
$/IronPython/IronPython_Main/Src/Tests/test_python25.py
$/IronPython/IronPython_Main/Src/Tests/test_namebinding.py



___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] -X:EnableProfiler and DLR hosting API (2.6b2)

2009-08-06 Thread Michael Foord

Dino Viehland wrote:

Err, I guess I mean -?.  I think we have a bug to support /? :)
  


Thanks

Michael

-Original Message-
From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Michael Foord
Sent: Thursday, August 06, 2009 8:31 AM
To: Discussion of IronPython
Subject: Re: [IronPython] -X:EnableProfiler and DLR hosting API (2.6b2)

Dino Viehland wrote:
  

All the options should be the same as the command line options.  So
they're documented via ipy.exe /? :)




C:\compile>"c:\Program Files\IronPython 2.6\ipy.exe" /?
File /? does not exist.
  

-Original Message-
From: users-boun...@lists.ironpython.com
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Michael Foord
Sent: Wednesday, August 05, 2009 4:07 PM
To: Discussion of IronPython
Subject: Re: [IronPython] -X:EnableProfiler and DLR hosting API
(2.6b2)

David DiCato wrote:



You have to pass the required options to Python.CreateEngine, like so:

var options = new Dictionary();

options["EnableProfiler"] = ScriptingRuntimeHelpers.True;

ver engine = Python.CreateEngine(options);


  

Are these options for IronPython 2.6 documented anywhere?

Michael




Hope this helps,

- David

*From:* users-boun...@lists.ironpython.com
[mailto:users-boun...@lists.ironpython.com] *On Behalf Of *Mads
Weitling
*Sent:* Wednesday, August 05, 2009 12:54 AM
*To:* users@lists.ironpython.com
*Subject:* [IronPython] -X:EnableProfiler and DLR hosting API (2.6b2)

Hi all and many thanks to Dino Viehland for answering my previous
question re: sys.builtin_module_names and embedding.

I am trying to use the IronPython profiler
(http://blogs.msdn.com/curth/archive/2009/03/29/an-ironpython-profile
r
.aspx) from an embedded interpreter but cannot figure out how to pass
the -X:EnableProfiler to my ScriptEngine instance.

_engine = Python.CreateEngine();

Debug.WriteLine(_engine.Runtime.Setup.HostArguments.IsReadOnly);

// prints True

_engine.Runtime.Setup.HostArguments.Add("-X:EnableProfiler")

// throws an System.NotSupportedException

How do I set up the Runtime.Setup.HostArguments before calling
Python.CreateEngine()?


/Mads

-
-
--

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


  

--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog


___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com





--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog


___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
  



--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog


___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] -X:EnableProfiler and DLR hosting API (2.6b2)

2009-08-06 Thread Dino Viehland
Err, I guess I mean -?.  I think we have a bug to support /? :)

-Original Message-
From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Michael Foord
Sent: Thursday, August 06, 2009 8:31 AM
To: Discussion of IronPython
Subject: Re: [IronPython] -X:EnableProfiler and DLR hosting API (2.6b2)

Dino Viehland wrote:
> All the options should be the same as the command line options.  So
> they're documented via ipy.exe /? :)
>

C:\compile>"c:\Program Files\IronPython 2.6\ipy.exe" /?
File /? does not exist.
> -Original Message-
> From: users-boun...@lists.ironpython.com
> [mailto:users-boun...@lists.ironpython.com] On Behalf Of Michael Foord
> Sent: Wednesday, August 05, 2009 4:07 PM
> To: Discussion of IronPython
> Subject: Re: [IronPython] -X:EnableProfiler and DLR hosting API
> (2.6b2)
>
> David DiCato wrote:
>
>> You have to pass the required options to Python.CreateEngine, like so:
>>
>> var options = new Dictionary();
>>
>> options["EnableProfiler"] = ScriptingRuntimeHelpers.True;
>>
>> ver engine = Python.CreateEngine(options);
>>
>>
>
> Are these options for IronPython 2.6 documented anywhere?
>
> Michael
>
>
>> Hope this helps,
>>
>> - David
>>
>> *From:* users-boun...@lists.ironpython.com
>> [mailto:users-boun...@lists.ironpython.com] *On Behalf Of *Mads
>> Weitling
>> *Sent:* Wednesday, August 05, 2009 12:54 AM
>> *To:* users@lists.ironpython.com
>> *Subject:* [IronPython] -X:EnableProfiler and DLR hosting API (2.6b2)
>>
>> Hi all and many thanks to Dino Viehland for answering my previous
>> question re: sys.builtin_module_names and embedding.
>>
>> I am trying to use the IronPython profiler
>> (http://blogs.msdn.com/curth/archive/2009/03/29/an-ironpython-profile
>> r
>> .aspx) from an embedded interpreter but cannot figure out how to pass
>> the -X:EnableProfiler to my ScriptEngine instance.
>>
>> _engine = Python.CreateEngine();
>>
>> Debug.WriteLine(_engine.Runtime.Setup.HostArguments.IsReadOnly);
>>
>> // prints True
>>
>> _engine.Runtime.Setup.HostArguments.Add("-X:EnableProfiler")
>>
>> // throws an System.NotSupportedException
>>
>> How do I set up the Runtime.Setup.HostArguments before calling
>> Python.CreateEngine()?
>>
>>
>> /Mads
>>
>> -
>> -
>> --
>>
>> ___
>> Users mailing list
>> Users@lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>
>>
>
>
> --
> http://www.ironpythoninaction.com/
> http://www.voidspace.org.uk/blog
>
>
> ___
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> ___
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>


--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog


___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] -X:EnableProfiler and DLR hosting API (2.6b2)

2009-08-06 Thread Michael Foord

Dino Viehland wrote:

All the options should be the same as the command line options.  So they're
documented via ipy.exe /? :)
  


C:\compile>"c:\Program Files\IronPython 2.6\ipy.exe" /?
File /? does not exist.

-Original Message-
From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Michael Foord
Sent: Wednesday, August 05, 2009 4:07 PM
To: Discussion of IronPython
Subject: Re: [IronPython] -X:EnableProfiler and DLR hosting API (2.6b2)

David DiCato wrote:
  

You have to pass the required options to Python.CreateEngine, like so:

var options = new Dictionary();

options["EnableProfiler"] = ScriptingRuntimeHelpers.True;

ver engine = Python.CreateEngine(options);




Are these options for IronPython 2.6 documented anywhere?

Michael

  

Hope this helps,

- David

*From:* users-boun...@lists.ironpython.com
[mailto:users-boun...@lists.ironpython.com] *On Behalf Of *Mads
Weitling
*Sent:* Wednesday, August 05, 2009 12:54 AM
*To:* users@lists.ironpython.com
*Subject:* [IronPython] -X:EnableProfiler and DLR hosting API (2.6b2)

Hi all and many thanks to Dino Viehland for answering my previous
question re: sys.builtin_module_names and embedding.

I am trying to use the IronPython profiler
(http://blogs.msdn.com/curth/archive/2009/03/29/an-ironpython-profiler
.aspx) from an embedded interpreter but cannot figure out how to pass
the -X:EnableProfiler to my ScriptEngine instance.

_engine = Python.CreateEngine();

Debug.WriteLine(_engine.Runtime.Setup.HostArguments.IsReadOnly);

// prints True

_engine.Runtime.Setup.HostArguments.Add("-X:EnableProfiler")

// throws an System.NotSupportedException

How do I set up the Runtime.Setup.HostArguments before calling
Python.CreateEngine()?


/Mads

--
--

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com





--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog


___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
  



--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog


___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] -X:EnableProfiler and DLR hosting API (2.6b2)

2009-08-06 Thread Dino Viehland
All the options should be the same as the command line options.  So they're
documented via ipy.exe /? :)

-Original Message-
From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Michael Foord
Sent: Wednesday, August 05, 2009 4:07 PM
To: Discussion of IronPython
Subject: Re: [IronPython] -X:EnableProfiler and DLR hosting API (2.6b2)

David DiCato wrote:
>
> You have to pass the required options to Python.CreateEngine, like so:
>
> var options = new Dictionary();
>
> options["EnableProfiler"] = ScriptingRuntimeHelpers.True;
>
> ver engine = Python.CreateEngine(options);
>

Are these options for IronPython 2.6 documented anywhere?

Michael

> Hope this helps,
>
> - David
>
> *From:* users-boun...@lists.ironpython.com
> [mailto:users-boun...@lists.ironpython.com] *On Behalf Of *Mads
> Weitling
> *Sent:* Wednesday, August 05, 2009 12:54 AM
> *To:* users@lists.ironpython.com
> *Subject:* [IronPython] -X:EnableProfiler and DLR hosting API (2.6b2)
>
> Hi all and many thanks to Dino Viehland for answering my previous
> question re: sys.builtin_module_names and embedding.
>
> I am trying to use the IronPython profiler
> (http://blogs.msdn.com/curth/archive/2009/03/29/an-ironpython-profiler
> .aspx) from an embedded interpreter but cannot figure out how to pass
> the -X:EnableProfiler to my ScriptEngine instance.
>
> _engine = Python.CreateEngine();
>
> Debug.WriteLine(_engine.Runtime.Setup.HostArguments.IsReadOnly);
>
> // prints True
>
> _engine.Runtime.Setup.HostArguments.Add("-X:EnableProfiler")
>
> // throws an System.NotSupportedException
>
> How do I set up the Runtime.Setup.HostArguments before calling
> Python.CreateEngine()?
>
>
> /Mads
>
> --
> --
>
> ___
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>


--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog


___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] FW: App_Script Problem in latest IronPython for ASP.Net

2009-08-06 Thread Jimmy Schementi
I've reproduced this issue. Microsoft.Web.Scripting seems to be doing the right 
thing ... detecting changes in App_Script and calling runtime.ExecuteFile(path) 
for the files that changed. However, that's not having any effect. This 
definitely works stand-alone, so I'll drill into this more. Thanks for the bug 
report though!

~js


From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Adam Brand
Sent: Tuesday, August 04, 2009 9:15 AM
To: Discussion of IronPython
Subject: Re: [IronPython] FW: App_Script Problem in latest IronPython for 
ASP.Net

Thanks. The previous release had the correct behavior, so hopefully it isn't 
hard to do.

Adam

Adam Brand
SilverKey Technologies

From: 
users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com]
 On Behalf Of Jimmy Schementi
Sent: Tuesday, August 04, 2009 9:13 AM
To: Discussion of IronPython
Subject: Re: [IronPython] FW: App_Script Problem in latest IronPython for 
ASP.Net

Not yet, sorry. I think I can fix that for the next release and make them 
reload if they've been modified, but I haven't checked if there is a way to do 
that today. I'll take a look now...

~Jimmy
Sent from my phone

On Aug 4, 2009, at 8:57 AM, "Adam Brand" 
mailto:ad...@silverkeytech.com>> wrote:
Any update on this?
On Fri, Jun 12, 2009 at 2:47 PM, Jimmy Schementi 
mailto:jimmy.scheme...@microsoft.com>> wrote:

Not sure if it's by design or just failing to reload it correctly. I'll take a 
look shortly.



From: 
users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com]
 On Behalf Of Adam Brand
Sent: Friday, June 12, 2009 8:54 AM
To: Discussion of IronPython
Subject: [IronPython] FW: App_Script Problem in latest IronPython for 
ASP.Net



Does anyone have any insight into this?



Thanks,

Adam



Adam Brand

SilverKey Technologies



From: Adam Brand 
[mailto:ad...@silverkeytech.com]
Sent: Sunday, May 31, 2009 7:53 AM
To: 'Discussion of IronPython'
Subject: App_Script Problem in latest IronPython for ASP.Net



I've noticed that with the latest bits for IronPython for 
ASP.Net, files in app_script only seem to be revisited when the 
app pool is restarted.



For example, if I have a file called hello_world.py in App_Script, and delete 
that file, the app still executes code in that file as if it were there. If I 
change a line in the file, that line is not shown as changed until I restart 
the app pool.



Is this by design, a bug, or something I'm doing wrong?



Thanks,

Adam

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



--
Adam Brand

Managing Partner
SilverKey Technologies

Direct: +1-312-239-6722
Main: +1-312-951-7525
Skype: adamsilverkey
Email: ad...@silverkeytech.com
www.silverkeytech.com
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] -X:EnableProfiler and DLR hosting API

2009-08-06 Thread Mads Weitling
Thank you for the answer :)
I found this article which tells me that a script can now enable the
profiler from within itself:

http://blogs.msdn.com/curth/archive/2009/04/11/profiler-part-ii-poor-man-s-code-coverage.aspx

So
I used that method instead, like this:

def begin_profiler():
import clr
clr.EnableProfiler(True)
clr.ClearProfilerData()

def end_profiler():
ticks_to_ms = 0.1
clr.EnableProfiler(False)
# show top 20 sorted by exclusive time
for p in itertools.islice(sorted(filter(lambda item: item.Calls != 0,
clr.GetProfilerData(True)), key=lambda item: -item.InclusiveTime), 20):
print '%s\n%f\t%f\t%d' % (p.Name, p.InclusiveTime * ticks_to_ms,
p.ExclusiveTime * ticks_to_ms, p.Calls)

Seems to work very well :)

/Mads
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com