Re: [IronPython] weird performance issue

2008-12-16 Thread Dino Viehland
My guess would be that we're pushing the PythonContext._callSplatSite outside of the sweet spot in DLR site caches. You could check this by putting a breakpoint in PythonContext.Call(object, params object[]). Then look and see if _callSplatSite._rules is an instance of EmptyRuleSet with _suppo

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread Kristian Jaksch
Michael, Thank you for your help! It finally works. Now there is lots of other things left but this has really helped a lot. 2008/12/16 Michael Foord > Kristian Jaksch wrote: > >> >> Michael, >> >> What do you mean exec the import * inside the context to poulate it? >> Something like: >> >> *

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread Michael Foord
Kristian Jaksch wrote: Michael, What do you mean exec the import * inside the context to poulate it? Something like: *context['Mapack'] = exec "from Mapack import *" #Doesn't work *Hmmm... think I'm getting tired. exec doesn't return anything. Try: *exec "from Mapack import *" in cont

[IronPython] weird performance issue

2008-12-16 Thread Kamil Dworakowski
We see a very strange side effect of running the follwing code on the performance of recalculations in Resolver One. def Dumbcorator(fn): def _inner(self, *args): return fn(self, *args) return _inner class Locker(object): @property @Dumbcorator def thing(self):

[IronPython] weird performance issue

2008-12-16 Thread Kamil Dworakowski
We see a very strange side effect of running the follwing code on the performance of recalculations in Resolver One. def Dumbcorator(fn): def _inner(self, *args): return fn(self, *args) return _inner class Locker(object): @property @Dumbcorator def thing(self):

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread Kristian Jaksch
Orestis, passing the 'context' to 'eval' seems like the right thing to do. I tried your solution, see below: * clr.AddReference("Mapack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null") from Mapack import *** #A library that contain classes for working with algebra etc.* . . . *contex

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread Michael Foord
Michael Foord wrote: Kristian Jaksch wrote: * def inputBox_KeyDown(s, e): key = e.Key.value__ result = root.inputBox.Text if key == 3: #If 'Enter' key is pressed try: try: root.message.Text = eval(result) except SyntaxError: exec result in

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread Orestis Markou
you have to pass the context to eval as well: eval(result, context) make sure that the context doesn't change between calls to eval and exec. It should be a property on your form, really, but it doesn't seem so. Just make sure that you don't re-create the context every time. If you don't wan

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread Michael Foord
Kristian Jaksch wrote: Ok, did you mean something like below?: * clr.AddReference("Mapack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null") from Mapack import *** #A library that contain classes for working with algebra etc.* *context = {} context['m'] = Matrix(5,5)#creating

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread Kristian Jaksch
Ok, did you mean something like below?: * clr.AddReference("Mapack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null") from Mapack import *** #A library that contain classes for working with algebra etc.* *context = {} context['m'] = Matrix(5,5)#creating a 5 rows, 5 columns matrix o

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread Michael Foord
xkrja wrote: Thanks! I'm using Ironpython with Silverlight so I can't get access to Windows.Forms Ah - in which case it probably lives in System.Windows.Input Please bear with me :-) New stuff's showing up all the time. The solution you proposed worked but there must be something I don't g

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread xkrja
Thanks! I'm using Ironpython with Silverlight so I can't get access to Windows.Forms Please bear with me :-) New stuff's showing up all the time. The solution you proposed worked but there must be something I don't get with the scope. Please look at my snippet below: import clr, sys clr.AddRef

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread Michael Foord
Oh - and Windows Forms has a Keys enumeration so that you don't have to rely on the underlying value of the event key property. from System.Windows.Forms import Keys if e.Key == Keys.Enter: (or something like that - check out the MSDN documentation for the enumeration.) Michael Foord Mich

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread Michael Foord
context = {} def inputBox_KeyDown(s, e): root.message.Text = '' key = e.Key.value__ result = root.inputBox.Text if key == 3: #If 'Enter' key is pressed try: try: root.message.Text = eval(result) except SyntaxError: exec result in contex

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread xkrja
Thanks for the reply. Below is a snippet of what I've got: def inputBox_KeyDown(s, e): root.message.Text = '' key = e.Key.value__ result = root.inputBox.Text if key == 3: #If 'Enter' key is pressed try: root.message.Text = eval(result) except:

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread Michael Foord
xkrja wrote: Thanks for the replies guys. I tried the solution below and it works in some cases. But a strange thing is (remember I'm a newbie) that if I first type, for example a=1 in the "inputBox" and then hit enter, the debugger goes down to exec root.inputBox.Text and nothing is reported so

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread xkrja
Thanks for the replies guys. I tried the solution below and it works in some cases. But a strange thing is (remember I'm a newbie) that if I first type, for example a=1 in the "inputBox" and then hit enter, the debugger goes down to exec root.inputBox.Text and nothing is reported so I assume the

Re: [IronPython] Modules importing each other

2008-12-16 Thread Michael Foord
You would find the same thing in CPython. When you execute Program.py it is run with the name '__main__' (the main program being executed). When you import it, you import it with the name 'Program' which causes it to be imported with a different name. I suggest you put your debug symbol in a se

[IronPython] Modules importing each other

2008-12-16 Thread Yash Ganthe
I use IronPython 2.0. In Program.py I have: print "hello" DEBUGMODE=0 . . . import LogMessage In LogMessage.py I have from Program import DEBUGMODE When I run : ipy Program.py I observe that "hello" is printed twice: Once when Program.py is run and next when a symbol from Program.py is imported

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread Douglas Blank
This is just a Python issue (not specific to IronPython). exec is used for statement(s) and eval() for expressions. You might have to: try: eval(root.inputBox.Text) except: exec root.inputBox.Text -Doug - xkrja wrote: > > Thanks for the reply. This is what I have: > > def inputBox_

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread Michael Foord
xkrja wrote: Thanks for the reply. This is what I have: def inputBox_KeyDown(s, e): root.message.Text = '' key = e.Key.value__ if key == 3: result = eval(root.inputBox.Text) root.message.Text = str(result) eval() seems to work sometimes. For example if the text in th

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread xkrja
Thanks for the reply. This is what I have: def inputBox_KeyDown(s, e): root.message.Text = '' key = e.Key.value__ if key == 3: result = eval(root.inputBox.Text) root.message.Text = str(result) eval() seems to work sometimes. For example if the text in the textbox is 1

Re: [IronPython] IronPython and file descriptors

2008-12-16 Thread Tom Wright
I'm not sure about sockets. The only example I have found in the wild so far is with files in PIL. The python implementation seems to have socket.fileno() returning a file descriptor which comes from 's socketpair function in the standard C library (see socketmodule.c if you are interested)

Re: [IronPython] Newbie: convert string to python expression??

2008-12-16 Thread Konrad Delong
2008/12/16 xkrja : > > Hi, > I'm just starting out learning IronPython. How can I convert a string that > someone writes in a textbox to a python expression or statement?? Compare it > to the console input: If I write for example a=2 in the console it's not > just a string I assume? It becomes an e

[IronPython] Newbie: convert string to python expression??

2008-12-16 Thread xkrja
Hi, I'm just starting out learning IronPython. How can I convert a string that someone writes in a textbox to a python expression or statement?? Compare it to the console input: If I write for example a=2 in the console it's not just a string I assume? It becomes an expression in the python code o

Re: [IronPython] Help contents

2008-12-16 Thread Hernán Martínez Foffani
Thanks a lot again. > If you have only one version/culture, I believe you can just place > the XML doc in the same directory as the DLL. > > >> >> It seems clear now, thank you. >> >> Reading DocBuilder.cs:GetXPathDocument(..) I assume that if I want >> to let our users to be able to get IP c