From thane at magna-capital.com Sat Apr 1 05:32:48 2006 From: thane at magna-capital.com (Thane Plummer) Date: Fri, 31 Mar 2006 22:32:48 -0500 Subject: [IronPython] [Python.NET] Naming and resolution of generic types (complete!) In-Reply-To: <65531D426735784F854EE658938A585302798CCA@MI8NYCMAIL03.Mi8.com> Message-ID: <002c01c6553c$f378b250$6603a8c0@Dell9150> My vote is to keep Python pure, i.e. import SomeGeneric_TT or foo = TwoParamGeneric<<2 are simply un-Pythonic. It is amusing that the .NET framework has incorporated a feature --Generics-- that make it more useful, and indeed more like Python, and the Python community is now trying to emulate a solution that has already been solved in Python! OK, I'm generalizing and I recognize that there are exceptions; but by and large, Generics give .NET programmers the flexibility that Python users have always had. The vast majority of programming objectives can be met using plain old Python. Really. A problem arises when there is a .NET system call or 3rd party library that expects Generics in its interface. In those cases, why not just coerce the native Python type and throw an exception if the programmer did something stupid? >>> import generic_interface_lib >>> int_list = [1, 2, 3, "Hey! A string!", 5, 6] >>> result = generic_interface_lib.Plot(int_list) Traceback (most recent call last): File "", line 1, in ? Do_Not_Be_A_Bozo Exception: function requires a list of numbers. Yes, I do know the answer to the previous question, but this seems to be a more Pythonic solution. Brian's question makes me wonder if Python can be all things to all programmers, and my thinking is: no, it can't. Trying to make it so will just pollute the language. --Thane -----Original Message----- From: pythondotnet-bounces at python.org [mailto:pythondotnet-bounces at python.org] On Behalf Of Brian Lloyd Sent: Friday, March 31, 2006 3:43 PM To: pythondotnet at python.org Cc: users at lists.ironpython.com Subject: [Python.NET] Naming and resolution of generic types (complete!) Hi all - I'm cross-posting this to the IP list as the subject seems to be an open issue there too. I'm working on generics support for Python for .NET, and there a couple of thorny issues that could use some discussion regarding naming and resolution of generic types. In C# you can explicitly name a generic type, a la Dictionary<,>. That syntax won't work in Python, of course. Looking at IP, it seems to allow the apparent Python name to be the unmangled IL name so you can naturally use the name. The problem is that the mangled name is illegal as a python name, and the unmangled name isn't guaranteed to be unique - you can potentially have any number of generic types as well as a non-generic type with the same base name in the same namespace: namespace Spam { public class SpamCan {} public class SpamCan {} public class SpamCan {} ... } I imagine that maybe IP has enough information available at compile-time to do the right thing for some common usage (binding and instantiating the types), but the overloaded name can still be ambiguous. A real-life example of this is System.IComparable - in IP, it doesn't seem possible to get to the non-generic version of IComparable anymore (or at least it was not obvious to me how to do it): >>> import System >>> System.IComparable It seems like we need to figure out some acceptable way of spelling generic type names explicitly in Python (an equivalent to IComparable<> in C#) that works within the existing syntax. There don't appear to be a lot of great options :( It has to be a valid Python name to work in an import statement, so that rules out strange operator shenanigans akin to the [] hack used for generic type binding. One would be to mimic the existing IL mangling in some way, a la: >From System import IComparable # the non-generic type >From System import IComparable_1 # the 1-param generic # or from System import IComparable_T from System.Collections.Generic import Dictionary_TT These are all pretty gross, and still don't totally prevent hiding of legit non-generic classes with those names (though it makes it less likely that names will be hidden than the current approach). I suppose another approach would be to continue to have only one type end up with the simple name, but provide a way to disambiguate it after the fact: >>> import System >>> System.IComparable >>> # abandon all hope, ye who enter here... >>> NonGenericIComparable = System.IComparable<<0 >>> OneParamGenericIComparable = System.IComparable<<1 >>> TwoParamVersionIfThereWasOne = System.IComparable<<2 That feels to me like it violates Python Zen in several ways, though. Thoughts? -Brian _________________________________________________ Python.NET mailing list - PythonDotNet at python.org http://mail.python.org/mailman/listinfo/pythondotnet From mat at matssoftware.co.uk Sat Apr 1 16:20:02 2006 From: mat at matssoftware.co.uk (Mat Steeples) Date: Sat, 1 Apr 2006 15:20:02 +0100 Subject: [IronPython] bug: Newline isn\'t put written before the Console Prompt Message-ID: <0505055216b7ee217b34393e30d3dcd9@localhost> Hi This is on IronPython beta 5, and happens when you\'ve got an output to the console that doesn\'t print a new line. For example, the tutorial I\'m working through shows you how to print the Fibonacci series: >>> a, b = 0, 1 >>> while b < 1000: ... print b, ... a, b = b, a+b ... 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 The prompt (\">>>\") on IronPython appears after the 987, rather than on the next line. Hope this is enough information. I tried having a look through the source for the location of this, but I\'m new to IP, so I figured it would be more productinve to post it to this list! :) Cheers, Mat Steeples PS: I know it\'s picky as well, but could the command line args accept ColourfulConsole as well as ColorfulConsole, as it\'s really difficult being a brit to spell colour without a u! :) From korpse-ironpython at kaydash.za.net Sun Apr 2 11:05:56 2006 From: korpse-ironpython at kaydash.za.net (Jonathan Jacobs) Date: Sun, 02 Apr 2006 11:05:56 +0200 Subject: [IronPython] Issues with the OptimizedFunctionAny Message-ID: <442F93F4.3080808@kaydash.za.net> Hi, I've stumbled across this interesting behaviour: >>> p = ((1, 2),) >>> zip(*(p * 10)) [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2, 2, 2, 2)] >>> zip(*(p * 10)) Traceback (most recent call last): File , line 0, in input##10 TypeError: zip() takes at most 0 arguments (10 given) Upon the first-time calling the method it is a "ReflectedMethod" object, this is then optimized (compiled?) to an "OptimizedFunctionAny" object somewhere along the line, which appears to have problems accepting more than 5 parameters (according to the source code, anyway.) This seems like a pretty serious issue. Is there any way I can get around it in the meanwhile? Regards -- Jonathan When you meet a master swordsman, show him your sword. When you meet a man who is not a poet, do not show him your poem. -- Rinzai, ninth century Zen master From furtwan1 at msu.edu Sun Apr 2 18:06:37 2006 From: furtwan1 at msu.edu (Brandon Furtwangler) Date: Sun, 2 Apr 2006 12:06:37 -0400 Subject: [IronPython] progress toward 1.0 In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E023F521F@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <20060402160646.0095A1BB53@che.dreamhost.com> Great to see another beta release of IP. I really like the short turnover time between betas because it keeps us all in the know, so to speak. My question is when we can expect a 1.0 release? Obviously we wont see it until its ready, but is there a general timeframe? -Brandon -------------- next part -------------- An HTML attachment was scrubbed... URL: From dreshae at voila.fr Sun Apr 2 19:00:09 2006 From: dreshae at voila.fr (dreshae at voila.fr) Date: Sun, 2 Apr 2006 19:00:09 +0200 (CEST) Subject: [IronPython] IronPython WinForms Message-ID: <7605127.1143997208967.JavaMail.www@wwinf4003> Hello, my question is simple : How to create, with WinForms, a MenuBar ( or MainMenu ) ? with IronPython of course -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Sun Apr 2 22:16:25 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Sun, 2 Apr 2006 13:16:25 -0700 Subject: [IronPython] Issues with the OptimizedFunctionAny In-Reply-To: <442F93F4.3080808@kaydash.za.net> Message-ID: <4039D552ADAB094BB1EA670F3E96214E023F5A01@df-foxhound-msg.exchange.corp.microsoft.com> At the console there's an easy workaround: >>> zip = zip >>> p = ((1,2),) >>> zip(*(p*10)) [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2, 2, 2, 2)] >>> zip(*(p*10)) [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2, 2, 2, 2)] Unfortunately that doesn't help you in a module where we'll always optimize the method. Another work around that involves changing the source code is updating CanOptimize(MethodBase mi) in IronPython\Compiler\ReflectOptimizer.cs. You can just add something like: if(mi.Name == "zip") return false; and it'll suppress the optimization of that method. We should actually be able to handle more than 5 arguments in this case (via a params arg) so hopefully it's just a simple bug, but I'll have to look into it. The optimization it's self is switching from a late-bound method invocation via reflection to an optimized caller stub. The 5 args limit is for non-params args (it's tricky because we get into having mixed # of arguments in the same method). Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jonathan Jacobs Sent: Sunday, April 02, 2006 1:06 AM To: IronPython List Subject: [IronPython] Issues with the OptimizedFunctionAny Hi, I've stumbled across this interesting behaviour: >>> p = ((1, 2),) >>> zip(*(p * 10)) [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2, 2, 2, 2)] >>> zip(*(p * 10)) Traceback (most recent call last): File , line 0, in input##10 TypeError: zip() takes at most 0 arguments (10 given) Upon the first-time calling the method it is a "ReflectedMethod" object, this is then optimized (compiled?) to an "OptimizedFunctionAny" object somewhere along the line, which appears to have problems accepting more than 5 parameters (according to the source code, anyway.) This seems like a pretty serious issue. Is there any way I can get around it in the meanwhile? Regards -- Jonathan When you meet a master swordsman, show him your sword. When you meet a man who is not a poet, do not show him your poem. -- Rinzai, ninth century Zen master _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Sun Apr 2 22:16:25 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Sun, 2 Apr 2006 13:16:25 -0700 Subject: [IronPython] Issues with the OptimizedFunctionAny In-Reply-To: <442F93F4.3080808@kaydash.za.net> Message-ID: <4039D552ADAB094BB1EA670F3E96214E023F5A01@df-foxhound-msg.exchange.corp.microsoft.com> At the console there's an easy workaround: >>> zip = zip >>> p = ((1,2),) >>> zip(*(p*10)) [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2, 2, 2, 2)] >>> zip(*(p*10)) [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2, 2, 2, 2)] Unfortunately that doesn't help you in a module where we'll always optimize the method. Another work around that involves changing the source code is updating CanOptimize(MethodBase mi) in IronPython\Compiler\ReflectOptimizer.cs. You can just add something like: if(mi.Name == "zip") return false; and it'll suppress the optimization of that method. We should actually be able to handle more than 5 arguments in this case (via a params arg) so hopefully it's just a simple bug, but I'll have to look into it. The optimization it's self is switching from a late-bound method invocation via reflection to an optimized caller stub. The 5 args limit is for non-params args (it's tricky because we get into having mixed # of arguments in the same method). Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jonathan Jacobs Sent: Sunday, April 02, 2006 1:06 AM To: IronPython List Subject: [IronPython] Issues with the OptimizedFunctionAny Hi, I've stumbled across this interesting behaviour: >>> p = ((1, 2),) >>> zip(*(p * 10)) [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2, 2, 2, 2)] >>> zip(*(p * 10)) Traceback (most recent call last): File , line 0, in input##10 TypeError: zip() takes at most 0 arguments (10 given) Upon the first-time calling the method it is a "ReflectedMethod" object, this is then optimized (compiled?) to an "OptimizedFunctionAny" object somewhere along the line, which appears to have problems accepting more than 5 parameters (according to the source code, anyway.) This seems like a pretty serious issue. Is there any way I can get around it in the meanwhile? Regards -- Jonathan When you meet a master swordsman, show him your sword. When you meet a man who is not a poet, do not show him your poem. -- Rinzai, ninth century Zen master _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Sun Apr 2 22:32:51 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Sun, 2 Apr 2006 13:32:51 -0700 Subject: [IronPython] Issues with the OptimizedFunctionAny In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E023F5A01@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E023F5A08@df-foxhound-msg.exchange.corp.microsoft.com> The real fix is to add this function to BuiltinFunction.Generated.cs in OptimizedFunctionAny: public override object Call(ICallerContext context, params object[] args) { if (IsContextAware) { object[] newArgs = new object[args.Length + 1]; newArgs[0] = context; Array.Copy(args, 0, newArgs, 1, args.Length); return Call(newArgs); } return Call(args); } The optimizer is actually doing its job - infact the first call goes through the optimized path, but it comes at it from a slightly different direction. The problem is that in beta 5 we made functions that take context (hasattr, getattr, setattr are the big ones here) could also be optimized. But we apparently missed the large of # arguments case. Thanks for the bug report, hopefully this will unblock you, and we'll get it fixed in beta 6. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland Sent: Sunday, April 02, 2006 1:16 PM To: Discussion of IronPython; IronPython List Subject: Re: [IronPython] Issues with the OptimizedFunctionAny At the console there's an easy workaround: >>> zip = zip >>> p = ((1,2),) >>> zip(*(p*10)) [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2, 2, 2, 2)] >>> zip(*(p*10)) [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2, 2, 2, 2)] Unfortunately that doesn't help you in a module where we'll always optimize the method. Another work around that involves changing the source code is updating CanOptimize(MethodBase mi) in IronPython\Compiler\ReflectOptimizer.cs. You can just add something like: if(mi.Name == "zip") return false; and it'll suppress the optimization of that method. We should actually be able to handle more than 5 arguments in this case (via a params arg) so hopefully it's just a simple bug, but I'll have to look into it. The optimization it's self is switching from a late-bound method invocation via reflection to an optimized caller stub. The 5 args limit is for non-params args (it's tricky because we get into having mixed # of arguments in the same method). Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jonathan Jacobs Sent: Sunday, April 02, 2006 1:06 AM To: IronPython List Subject: [IronPython] Issues with the OptimizedFunctionAny Hi, I've stumbled across this interesting behaviour: >>> p = ((1, 2),) >>> zip(*(p * 10)) [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2, 2, 2, 2)] >>> zip(*(p * 10)) Traceback (most recent call last): File , line 0, in input##10 TypeError: zip() takes at most 0 arguments (10 given) Upon the first-time calling the method it is a "ReflectedMethod" object, this is then optimized (compiled?) to an "OptimizedFunctionAny" object somewhere along the line, which appears to have problems accepting more than 5 parameters (according to the source code, anyway.) This seems like a pretty serious issue. Is there any way I can get around it in the meanwhile? Regards -- Jonathan When you meet a master swordsman, show him your sword. When you meet a man who is not a poet, do not show him your poem. -- Rinzai, ninth century Zen master _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Sun Apr 2 22:32:51 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Sun, 2 Apr 2006 13:32:51 -0700 Subject: [IronPython] Issues with the OptimizedFunctionAny In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E023F5A01@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E023F5A08@df-foxhound-msg.exchange.corp.microsoft.com> The real fix is to add this function to BuiltinFunction.Generated.cs in OptimizedFunctionAny: public override object Call(ICallerContext context, params object[] args) { if (IsContextAware) { object[] newArgs = new object[args.Length + 1]; newArgs[0] = context; Array.Copy(args, 0, newArgs, 1, args.Length); return Call(newArgs); } return Call(args); } The optimizer is actually doing its job - infact the first call goes through the optimized path, but it comes at it from a slightly different direction. The problem is that in beta 5 we made functions that take context (hasattr, getattr, setattr are the big ones here) could also be optimized. But we apparently missed the large of # arguments case. Thanks for the bug report, hopefully this will unblock you, and we'll get it fixed in beta 6. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland Sent: Sunday, April 02, 2006 1:16 PM To: Discussion of IronPython; IronPython List Subject: Re: [IronPython] Issues with the OptimizedFunctionAny At the console there's an easy workaround: >>> zip = zip >>> p = ((1,2),) >>> zip(*(p*10)) [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2, 2, 2, 2)] >>> zip(*(p*10)) [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2, 2, 2, 2)] Unfortunately that doesn't help you in a module where we'll always optimize the method. Another work around that involves changing the source code is updating CanOptimize(MethodBase mi) in IronPython\Compiler\ReflectOptimizer.cs. You can just add something like: if(mi.Name == "zip") return false; and it'll suppress the optimization of that method. We should actually be able to handle more than 5 arguments in this case (via a params arg) so hopefully it's just a simple bug, but I'll have to look into it. The optimization it's self is switching from a late-bound method invocation via reflection to an optimized caller stub. The 5 args limit is for non-params args (it's tricky because we get into having mixed # of arguments in the same method). Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jonathan Jacobs Sent: Sunday, April 02, 2006 1:06 AM To: IronPython List Subject: [IronPython] Issues with the OptimizedFunctionAny Hi, I've stumbled across this interesting behaviour: >>> p = ((1, 2),) >>> zip(*(p * 10)) [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2, 2, 2, 2)] >>> zip(*(p * 10)) Traceback (most recent call last): File , line 0, in input##10 TypeError: zip() takes at most 0 arguments (10 given) Upon the first-time calling the method it is a "ReflectedMethod" object, this is then optimized (compiled?) to an "OptimizedFunctionAny" object somewhere along the line, which appears to have problems accepting more than 5 parameters (according to the source code, anyway.) This seems like a pretty serious issue. Is there any way I can get around it in the meanwhile? Regards -- Jonathan When you meet a master swordsman, show him your sword. When you meet a man who is not a poet, do not show him your poem. -- Rinzai, ninth century Zen master _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From korpse-ironpython at kaydash.za.net Sun Apr 2 23:21:37 2006 From: korpse-ironpython at kaydash.za.net (Jonathan Jacobs) Date: Sun, 02 Apr 2006 23:21:37 +0200 Subject: [IronPython] Issues with the OptimizedFunctionAny In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E023F5A08@df-foxhound-msg.exchange.corp.microsoft.com> References: <4039D552ADAB094BB1EA670F3E96214E023F5A08@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <44304061.6030104@kaydash.za.net> Dino Viehland wrote: > The real fix is to add this function to BuiltinFunction.Generated.cs in OptimizedFunctionAny: Works beautifully now. Thanks! > Thanks for the bug report, hopefully this will unblock you, and we'll get it fixed in beta 6. Only too happy to help. -- Jonathan From dinov at exchange.microsoft.com Sun Apr 2 23:44:29 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Sun, 2 Apr 2006 14:44:29 -0700 Subject: [IronPython] progress toward 1.0 In-Reply-To: <20060402160646.0095A1BB53@che.dreamhost.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E023F5A15@df-foxhound-msg.exchange.corp.microsoft.com> Well, the goal is to keep the betas #s down to just a single digit... With releases every 3 weeks that should give you some idea... Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Brandon Furtwangler Sent: Sunday, April 02, 2006 9:07 AM To: 'Discussion of IronPython' Subject: [IronPython] progress toward 1.0 Great to see another beta release of IP. I really like the short turnover time between betas because it keeps us all in the know, so to speak. My question is when we can expect a 1.0 release? Obviously we wont see it until its ready, but is there a general timeframe? -Brandon -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Mon Apr 3 00:07:40 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Sun, 2 Apr 2006 15:07:40 -0700 Subject: [IronPython] IronPython WinForms In-Reply-To: <7605127.1143997208967.JavaMail.www@wwinf4003> Message-ID: <4039D552ADAB094BB1EA670F3E96214E023F5A17@df-foxhound-msg.exchange.corp.microsoft.com> This is the code the VSIP SDK generates w/ the IronPython integration sample: self._menuStrip1 = System.Windows.Forms.MenuStrip() self._fileToolStripMenuItem = System.Windows.Forms.ToolStripMenuItem() self._menuStrip1.SuspendLayout() self.SuspendLayout() # # menuStrip1 # self._menuStrip1.Items.AddRange(System.Array[System.Windows.Forms.ToolStripItem]((self._fileToolStripMenuItem, ))) self._menuStrip1.Location = System.Drawing.Point(0, 0) self._menuStrip1.Name = 'menuStrip1' self._menuStrip1.Size = System.Drawing.Size(292, 24) self._menuStrip1.TabIndex = 0 self._menuStrip1.Text = 'menuStrip1' # # fileToolStripMenuItem # self._fileToolStripMenuItem.Name = 'fileToolStripMenuItem' self._fileToolStripMenuItem.Size = System.Drawing.Size(35, 20) self._fileToolStripMenuItem.Text = 'File' # # Form1 # self.AutoScaleDimensions = System.Drawing.SizeF(6.0, 13.0) self.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font self.ClientSize = System.Drawing.Size(292, 266) self.Controls.Add(self._menuStrip1) self.MainMenuStrip = self._menuStrip1 self.Name = 'Form1' self.Text = 'Form1' self._menuStrip1.ResumeLayout(False) self._menuStrip1.PerformLayout() self.ResumeLayout(False) self.PerformLayout() Obviously you don't need a lot of this though, and it's the code for all of InitializeComponent. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of dreshae at voila.fr Sent: Sunday, April 02, 2006 10:00 AM To: users at lists.ironpython.com Subject: [IronPython] IronPython WinForms Hello, my question is simple : How to create, with WinForms, a MenuBar ( or MainMenu ) ? with IronPython of course -------------- next part -------------- An HTML attachment was scrubbed... URL: From sanxiyn at gmail.com Mon Apr 3 08:18:25 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Mon, 3 Apr 2006 15:18:25 +0900 Subject: [IronPython] Confirmation request Message-ID: <5b0248170604022318p2bf72bf6m6d843f98fcbcd36a@mail.gmail.com> First, I am sorry. But until bug tracker becomes public, I would like to receive ACK on following reports I sent: http://lists.ironpython.com/pipermail/users-ironpython.com/2006-March/001930.html http://lists.ironpython.com/pipermail/users-ironpython.com/2006-March/001975.html http://lists.ironpython.com/pipermail/users-ironpython.com/2006-March/001993.html Seo Sanghyeon From sanxiyn at gmail.com Mon Apr 3 11:08:15 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Mon, 3 Apr 2006 18:08:15 +0900 Subject: [IronPython] IronPython 1.0 Beta 5 on Mono In-Reply-To: <5b0248170603302210h5632761bu5e63f93e2ca8818c@mail.gmail.com> References: <5b0248170603301824o309de1cbv6f8828535cc85d22@mail.gmail.com> <5b0248170603302210h5632761bu5e63f93e2ca8818c@mail.gmail.com> Message-ID: <5b0248170604030208o7e8c4cc1s12ff6308419d4efd@mail.gmail.com> Below is the status with latest Mono SVN. I am using revision 58927. > IronPython/Runtime/SymbolTable.cs(95,33): error CS0262: Partial > declarations of `IronPython.Runtime.SymbolTable' have conflicting > accessibility modifiers This is Mono bug #77966. Fixed in SVN revision 58886. > IronPython/Compiler/FlowChecker.cs(158,13): error CS0117: > `System.Diagnostics.Debug' does not contain a definition for `Print' Fixed in SVN revision 58844. > IronPython/Runtime/PerfTrack.cs(44,13): error CS0246: The type or > namespace name `Stopwatch' could not be found. Are you missing a using > directive or an assembly reference? Stubbed in SVN revision 58896. In summary, latest Mono SVN will compile IronPython 1.0 Beta 5 out of the box. Seo Sanghyeon From mat at matssoftware.co.uk Mon Apr 3 11:46:08 2006 From: mat at matssoftware.co.uk (Mat Steeples) Date: Mon, 3 Apr 2006 10:46:08 +0100 (BST) Subject: [IronPython] Bug: Newline's are not shown from __doc__ properties Message-ID: <3865.212.50.186.5.1144057568.squirrel@maya.1575software.co.uk> Hi guys This occurrs in beta 5 of IronPython. Basically, if you try and show the output from a __doc__, it doesn't parse the newlines, and prints out the characters instead. I've pasted the output of an example below. This is the same with no command line arguements as it is with TabCompletion on. >>> import System >>> from System.Diagnostics import Process >>> Process.Start.__doc__ 'bool Start()\r\nstatic Process Start(str fileName, str userName, SecureString password, str domain) \r\nstatic Process Start(str fileName, str arguments, str userName, SecureString password, str domai n)\r\nstatic Process Start(str fileName)\r\nstatic Process Start(str fileName, str arguments)\r\nsta tic Process Start(ProcessStartInfo startInfo)\r\n' Hope that's enough detail. Regards, Mat Steeples From sanxiyn at gmail.com Mon Apr 3 11:58:50 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Mon, 3 Apr 2006 18:58:50 +0900 Subject: [IronPython] Bug: Newline's are not shown from __doc__ properties In-Reply-To: <3865.212.50.186.5.1144057568.squirrel@maya.1575software.co.uk> References: <3865.212.50.186.5.1144057568.squirrel@maya.1575software.co.uk> Message-ID: <5b0248170604030258r32e9287atf0f45b548a47a798@mail.gmail.com> 2006/4/3, Mat Steeples : > >>> Process.Start.__doc__ > 'bool Start()\r\nstatic Process Start(str fileName, str userName, > SecureString password, str domain) > \r\nstatic Process Start(str fileName, str arguments, str userName, > SecureString password, str domai > n)\r\nstatic Process Start(str fileName)\r\nstatic Process Start(str > fileName, str arguments)\r\nsta > tic Process Start(ProcessStartInfo startInfo)\r\n' You can do >>> print Process.Start.__doc__ instead. I don't consider this a bug. Seo Sanghyeon From mat at matssoftware.co.uk Mon Apr 3 12:01:05 2006 From: mat at matssoftware.co.uk (Mat Steeples) Date: Mon, 3 Apr 2006 11:01:05 +0100 (BST) Subject: [IronPython] Bug: Newline's are not shown from __doc__ properties In-Reply-To: <5b0248170604030258r32e9287atf0f45b548a47a798@mail.gmail.com> References: <3865.212.50.186.5.1144057568.squirrel@maya.1575software.co.uk> <5b0248170604030258r32e9287atf0f45b548a47a798@mail.gmail.com> Message-ID: <17397.212.50.186.5.1144058465.squirrel@maya.1575software.co.uk> > 2006/4/3, Mat Steeples : >> >>> Process.Start.__doc__ >> 'bool Start()\r\nstatic Process Start(str fileName, str userName, >> SecureString password, str domain) >> \r\nstatic Process Start(str fileName, str arguments, str userName, >> SecureString password, str domai >> n)\r\nstatic Process Start(str fileName)\r\nstatic Process Start(str >> fileName, str arguments)\r\nsta >> tic Process Start(ProcessStartInfo startInfo)\r\n' > > You can do >>>> print Process.Start.__doc__ > instead. > > I don't consider this a bug. > > Seo Sanghyeon > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > That's fantastic. Didn't realise that would make a difference. In that case I agree with you, it shouldn't be a bug. Regards, Mat Steeples From mat at matssoftware.co.uk Mon Apr 3 12:18:57 2006 From: mat at matssoftware.co.uk (Mat Steeples) Date: Mon, 3 Apr 2006 11:18:57 +0100 (BST) Subject: [IronPython] [Fwd: Intermittent Bug: Loading a py file crashes winforms] Message-ID: <34498.212.50.186.5.1144059537.squirrel@maya.1575software.co.uk> ---------------------------- Original Message ---------------------------- Subject: Intermittent Bug: Loading a py file crashes winforms From: "Mat Steeples" Date: Mon, April 3, 2006 10:59 am To: users at lists.ironpython.com -------------------------------------------------------------------------- Hi Sorry to keep posting new bugs like this. This one's quite a weird one. I've written a small .py file (attached) that when loading has some strange errors. If I type the code in by hand, then it runs no problems. If i drag the file over IronPythonConsole.exe, then it brings up the "Submit an error report" message. If i double click the file (so it loads with IronPythonConsole.exe) it runs fine (although the console window doesn't disappear when the form closes), and if I open IronPythonConsole and import the file, it prints out the following. 1 2 3 Traceback (most recent call last): File H:\IronPython-1.0-Beta5\sample.py, line 6, in Initialize AttributeError: 'Form' object has no attribute 'ShowDialog' Hope that's enough detail. The winforms.py file that I'm using is the one in the templates directory, but I've copied it to the lib directory. Regards, Mat Steeples --------------------- And now with the attached file! :) -------------- next part -------------- A non-text attachment was scrubbed... Name: sample.py Type: application/octet-stream Size: 79 bytes Desc: not available URL: From mat at matssoftware.co.uk Mon Apr 3 11:59:34 2006 From: mat at matssoftware.co.uk (Mat Steeples) Date: Mon, 3 Apr 2006 10:59:34 +0100 (BST) Subject: [IronPython] Intermittent Bug: Loading a py file crashes winforms Message-ID: <16000.212.50.186.5.1144058374.squirrel@maya.1575software.co.uk> Hi Sorry to keep posting new bugs like this. This one's quite a weird one. I've written a small .py file (attached) that when loading has some strange errors. If I type the code in by hand, then it runs no problems. If i drag the file over IronPythonConsole.exe, then it brings up the "Submit an error report" message. If i double click the file (so it loads with IronPythonConsole.exe) it runs fine (although the console window doesn't disappear when the form closes), and if I open IronPythonConsole and import the file, it prints out the following. 1 2 3 Traceback (most recent call last): File H:\IronPython-1.0-Beta5\sample.py, line 6, in Initialize AttributeError: 'Form' object has no attribute 'ShowDialog' Hope that's enough detail. The winforms.py file that I'm using is the one in the templates directory, but I've copied it to the lib directory. Regards, Mat Steeples From dinov at exchange.microsoft.com Mon Apr 3 18:19:59 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 3 Apr 2006 09:19:59 -0700 Subject: [IronPython] Confirmation request In-Reply-To: <5b0248170604022318p2bf72bf6m6d843f98fcbcd36a@mail.gmail.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E0249762D@df-foxhound-msg.exchange.corp.microsoft.com> Thanks for following up on these Seo... They're all in the bug database and we'll try and get them all fixed for beta 6. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sanghyeon Seo Sent: Sunday, April 02, 2006 11:18 PM To: users at lists.ironpython.com Subject: [IronPython] Confirmation request First, I am sorry. But until bug tracker becomes public, I would like to receive ACK on following reports I sent: http://lists.ironpython.com/pipermail/users-ironpython.com/2006-March/001930.html http://lists.ironpython.com/pipermail/users-ironpython.com/2006-March/001975.html http://lists.ironpython.com/pipermail/users-ironpython.com/2006-March/001993.html Seo Sanghyeon _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Mon Apr 3 18:21:30 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 3 Apr 2006 09:21:30 -0700 Subject: [IronPython] [Fwd: Intermittent Bug: Loading a py file crashes winforms] In-Reply-To: <34498.212.50.186.5.1144059537.squirrel@maya.1575software.co.uk> Message-ID: <4039D552ADAB094BB1EA670F3E96214E02497630@df-foxhound-msg.exchange.corp.microsoft.com> Indeed, this is the same behavior that CPython has: >>> def foo(): ... "\r\nabc\r\ndef" ... >>> foo.__doc__ '\r\nabc\r\ndef' >>> Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Mat Steeples Sent: Monday, April 03, 2006 3:19 AM To: users at lists.ironpython.com Subject: [IronPython] [Fwd: Intermittent Bug: Loading a py file crashes winforms] ---------------------------- Original Message ---------------------------- Subject: Intermittent Bug: Loading a py file crashes winforms From: "Mat Steeples" Date: Mon, April 3, 2006 10:59 am To: users at lists.ironpython.com -------------------------------------------------------------------------- Hi Sorry to keep posting new bugs like this. This one's quite a weird one. I've written a small .py file (attached) that when loading has some strange errors. If I type the code in by hand, then it runs no problems. If i drag the file over IronPythonConsole.exe, then it brings up the "Submit an error report" message. If i double click the file (so it loads with IronPythonConsole.exe) it runs fine (although the console window doesn't disappear when the form closes), and if I open IronPythonConsole and import the file, it prints out the following. 1 2 3 Traceback (most recent call last): File H:\IronPython-1.0-Beta5\sample.py, line 6, in Initialize AttributeError: 'Form' object has no attribute 'ShowDialog' Hope that's enough detail. The winforms.py file that I'm using is the one in the templates directory, but I've copied it to the lib directory. Regards, Mat Steeples --------------------- And now with the attached file! :) From dinov at exchange.microsoft.com Mon Apr 3 18:22:33 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 3 Apr 2006 09:22:33 -0700 Subject: [IronPython] Intermittent Bug: Loading a py file crashes winforms In-Reply-To: <16000.212.50.186.5.1144058374.squirrel@maya.1575software.co.uk> Message-ID: <4039D552ADAB094BB1EA670F3E96214E02497633@df-foxhound-msg.exchange.corp.microsoft.com> Posting new bugs is great! Thanks for reporting this. I'll get this one filed away but it sounds sufficiently weird that it will require some investigation before we know what's actually going on here. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Mat Steeples Sent: Monday, April 03, 2006 3:00 AM To: users at lists.ironpython.com Subject: [IronPython] Intermittent Bug: Loading a py file crashes winforms Hi Sorry to keep posting new bugs like this. This one's quite a weird one. I've written a small .py file (attached) that when loading has some strange errors. If I type the code in by hand, then it runs no problems. If i drag the file over IronPythonConsole.exe, then it brings up the "Submit an error report" message. If i double click the file (so it loads with IronPythonConsole.exe) it runs fine (although the console window doesn't disappear when the form closes), and if I open IronPythonConsole and import the file, it prints out the following. 1 2 3 Traceback (most recent call last): File H:\IronPython-1.0-Beta5\sample.py, line 6, in Initialize AttributeError: 'Form' object has no attribute 'ShowDialog' Hope that's enough detail. The winforms.py file that I'm using is the one in the templates directory, but I've copied it to the lib directory. Regards, Mat Steeples _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From kristof.wagemans at gmail.com Mon Apr 3 19:12:49 2006 From: kristof.wagemans at gmail.com (Kristof Wagemans) Date: Mon, 3 Apr 2006 19:12:49 +0200 Subject: [IronPython] Bug with string encoding while redirecting to a custom stream Message-ID: <000601c65741$d665bbc0$0f01a8c0@notebook> I needed to change the default ASCII encoding to Unicode because it removed all accented characters when sending data to my custom stream. While trying to get this to work I found the following problem. Use PythonEngine.SetStdout(), PythonEngine.SetStderr(), PythonEngine.SetStdin () to set your own custom stream. There is a PythonFile wrapper created around the stream with the default encoding specified. Then change the default encoding with sys.setdefaultencoding('utf_16_le'). The encoding of the PythonFile remains the same and it keeps sending data in the old format. I don't know how difficult it is to change this behavior and even if it's possible to change the encoding dynamically. An easy workaround for me is to change the default encoding first and then set the new streams. I'm only using sys.setdefaultencoding('utf_16_le') to specify the default encoding at startup of the PythonEngine. The setting that I want to change is inaccessible: DefaultEncoding is an internal value in SystemState. Maybe it would be a good idea to add this to the Options so that it's possible to directly start the PythonEngine with the desired encoding. ----- Something else: it would be nice if the __doc__ of enum's returned all the names of the constants instead of 'no documentation available'. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dreshae at voila.fr Tue Apr 4 08:37:37 2006 From: dreshae at voila.fr (dreshae at voila.fr) Date: Tue, 4 Apr 2006 08:37:37 +0200 (CEST) Subject: [IronPython] IronPython WinForms Message-ID: <22468456.1144132657358.JavaMail.www@wwinf4102> It works perfectly, thank you very much > Message du 03/04/06 ? 00h07 > De : "Dino Viehland" > A : "dreshae at voila.fr" , "Discussion of IronPython" > Copie ? : > Objet : Re: [IronPython] IronPython WinForms > > This is the code the VSIP SDK generates w/ the IronPython integration sample: self._menuStrip1 = System.Windows.Forms.MenuStrip() self._fileToolStripMenuItem = System.Windows.Forms.ToolStripMenuItem() self._menuStrip1.SuspendLayout() self.SuspendLayout() # # menuStrip1 # self._menuStrip1.Items.AddRange(System.Array[System.Windows.Forms.ToolStripItem]((self._fileToolStripMenuItem, ))) self._menuStrip1.Location = System.Drawing.Point(0, 0) self._menuStrip1.Name = 'menuStrip1' self._menuStrip1.Size = System.Drawing.Size(292, 24) self._menuStrip1.TabIndex = 0 self._menuStrip1.Text = 'menuStrip1' # # fileToolStripMenuItem # self._fileToolStripMenuItem.Name = 'fileToolStripMenuItem' self._fileToolStripMenuItem.Size = System.Drawing.Size(35, 20) self._fileToolStripMenuItem.Text = 'File' # # Form1 # self.AutoScaleDimensions = System.Drawing.SizeF(6.0, 13.0) self.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font self.ClientSize = System.Drawing.Size(292, 266) self.Controls.Add(self._menuStrip1) self.MainMenuStrip = self._menuStrip1 self.Name = 'Form1' self.Text = 'Form1' self._menuStrip1.ResumeLayout(False) self._menuStrip1.PerformLayout() self.ResumeLayout(False) self.PerformLayout() Obviously you don?t need a lot of this though, and it?s the code for all of InitializeComponent. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of dreshae at voila.fr > Sent: Sunday, April 02, 2006 10:00 AM > To: users at lists.ironpython.com > Subject: [IronPython] IronPython WinForms > Hello, my question is simple : How to create, with WinForms, a MenuBar ( or MainMenu ) ? with IronPython of course > > [ (pas de nom de fichier) (0.2 Ko) ] -------------- next part -------------- An HTML attachment was scrubbed... URL: From william at resolversystems.com Tue Apr 4 16:08:50 2006 From: william at resolversystems.com (William Reade) Date: Tue, 04 Apr 2006 15:08:50 +0100 Subject: [IronPython] Beta 5 bug: False == None? Message-ID: <44327DF2.9030900@resolversystems.com> ----------------------------------------------------------- IronPython 1.0.2280 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> False == None True ----------------------------------------------------------- The avove comparison should evaluate to False. It was working correctly in IP beta 4. However, "None == False" still (correctly) evaluates to False. Cheers William From yalvi at exchange.microsoft.com Tue Apr 4 18:15:59 2006 From: yalvi at exchange.microsoft.com (Yasir Alvi) Date: Tue, 4 Apr 2006 09:15:59 -0700 Subject: [IronPython] Beta 5 bug: False == None? In-Reply-To: <44327DF2.9030900@resolversystems.com> Message-ID: <2D38793E06D9DE449285146407202692027DBC59@df-foxhound-msg.exchange.corp.microsoft.com> Thanks for reporting this---I've filed a bug and we'll get this fixed for Beta 6. Thanks, Yasir -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of William Reade Sent: Tuesday, April 04, 2006 7:09 AM To: Discussion of IronPython Subject: [IronPython] Beta 5 bug: False == None? ----------------------------------------------------------- IronPython 1.0.2280 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> False == None True ----------------------------------------------------------- The avove comparison should evaluate to False. It was working correctly in IP beta 4. However, "None == False" still (correctly) evaluates to False. Cheers William _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Tue Apr 4 21:58:20 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Tue, 4 Apr 2006 12:58:20 -0700 Subject: [IronPython] Intermittent Bug: Loading a py file crashes winforms In-Reply-To: <16000.212.50.186.5.1144058374.squirrel@maya.1575software.co.uk> Message-ID: <4039D552ADAB094BB1EA670F3E96214E0249811A@df-foxhound-msg.exchange.corp.microsoft.com> The issue here is w/ the timing of starting up the Winforms thread and returning control back to your module. This will be fixed in beta 6, but you can make the change to winforms.py yourself by adding the marked 4 lines: from System.Drawing import Size from System.Windows.Forms import Form, Application from System.Threading import Thread from IronPython.Runtime import CallTarget0 from System.Threading import AutoResetEvent # add me import IronPython are = AutoResetEvent(False) # add me def thread_proc(): global dispatcher dispatcher = Form(Size = Size(0,0)) dispatcher.Show() dispatcher.Hide() are.Set() # add me Application.Run() def callback(code): if code: dispatcher.Invoke(CallTarget0(code)) else: Application.Exit() t = Thread(thread_proc) t.Start() are.WaitOne() # add me IronPython.Hosting.PythonEngine.ExecWrapper = callback Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Mat Steeples Sent: Monday, April 03, 2006 3:00 AM To: users at lists.ironpython.com Subject: [IronPython] Intermittent Bug: Loading a py file crashes winforms Hi Sorry to keep posting new bugs like this. This one's quite a weird one. I've written a small .py file (attached) that when loading has some strange errors. If I type the code in by hand, then it runs no problems. If i drag the file over IronPythonConsole.exe, then it brings up the "Submit an error report" message. If i double click the file (so it loads with IronPythonConsole.exe) it runs fine (although the console window doesn't disappear when the form closes), and if I open IronPythonConsole and import the file, it prints out the following. 1 2 3 Traceback (most recent call last): File H:\IronPython-1.0-Beta5\sample.py, line 6, in Initialize AttributeError: 'Form' object has no attribute 'ShowDialog' Hope that's enough detail. The winforms.py file that I'm using is the one in the templates directory, but I've copied it to the lib directory. Regards, Mat Steeples _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From sdrucker at microsoft.com Thu Apr 6 03:40:38 2006 From: sdrucker at microsoft.com (Steven Drucker) Date: Wed, 5 Apr 2006 18:40:38 -0700 Subject: [IronPython] Assembly differences in Beta5 Message-ID: With the switch to Beta5, my assembly loading is not working (again). Among other modules, I'm using the Microsoft Office Interop modules: I used to be able to do the following: import clr import System.Reflection clr.AddAssembly(System.Reflection.Assembly.LoadFrom('/code/dlls/Microsof t.Office.Interop.PowerPoint.dll')); clr.AddAssembly(System.Reflection.Assembly.LoadFrom('/code/dlls/office.d ll)); import Microsoft.Office.Interop.PowerPoint as PP import Microsoft.Office.Core as Core now, this says, TypeError, bad args for method (on the AddAssembly line) I've also used just about every combination of AddReferenceByName, PartialName, FromFile, LoadAssembly, etc. that I can think of. None of them work anymore...usually, they crap out on the import. What's the preferred/correct/possible way of doing this now? Thanks! --Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Thu Apr 6 04:42:08 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 5 Apr 2006 19:42:08 -0700 Subject: [IronPython] Assembly differences in Beta5 In-Reply-To: References: Message-ID: <4039D552ADAB094BB1EA670F3E96214E235C57@df-foxhound-msg.exchange.corp.microsoft.com> This should work: import clr import System.Reflection clr.AddReference(System.Reflection.Assembly.LoadFrom('/code/dlls/Microsoft.Office.Interop.PowerPoint.dll')); clr.AddReference(System.Reflection.Assembly.LoadFrom('/code/dlls/office.dll)); import Microsoft.Office.Interop.PowerPoint as PP import Microsoft.Office.Core as Core the key is the change from AddAssembly to AddReference. It's unfortunate you were using AddAssembly as it's really only there for compiled scripts to add themselves into the list of available assemblies (and the way we do that changed from using references to assemblies in beta 5), not for usage in scripts. It takes a string now instead of an assembly, which is the reason why you're getting that exception. We should move this out of clr to avoid future confusion. ________________________________ From: users-bounces at lists.ironpython.com On Behalf Of Steven Drucker Sent: Wednesday, April 05, 2006 6:40 PM To: Discussion of IronPython Subject: [IronPython] Assembly differences in Beta5 With the switch to Beta5, my assembly loading is not working (again). Among other modules, I'm using the Microsoft Office Interop modules: I used to be able to do the following: import clr import System.Reflection clr.AddAssembly(System.Reflection.Assembly.LoadFrom('/code/dlls/Microsoft.Office.Interop.PowerPoint.dll')); clr.AddAssembly(System.Reflection.Assembly.LoadFrom('/code/dlls/office.dll)); import Microsoft.Office.Interop.PowerPoint as PP import Microsoft.Office.Core as Core now, this says, TypeError, bad args for method (on the AddAssembly line) I've also used just about every combination of AddReferenceByName, PartialName, FromFile, LoadAssembly, etc. that I can think of. None of them work anymore...usually, they crap out on the import. What's the preferred/correct/possible way of doing this now? Thanks! --Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From sanxiyn at gmail.com Thu Apr 6 07:45:17 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Thu, 6 Apr 2006 14:45:17 +0900 Subject: [IronPython] base64 module Message-ID: <5b0248170604052245m75def21et8dc410151082f732@mail.gmail.com> Hello, base64 module documentation for b64decode function says, "TypeError is raised if s were incorrectly padded or if there are non-alphabet characters present in the string." But this doesn't seem to be the case. Testcase: import base64 base64.b64decode('%') Since % is a non-alphabet character, this should raise TypeError (btw, shouldn't this be ValueError instead?), but Python 2.4.3 silently ignores. I found this while experimenting with IronPython. IronPython 1.0 Beta 5 gives: Traceback (most recent call last): File base64, line unknown, in b64decode SystemError: cannot decode byte: '%' It's not TypeError, but it doesn't silently ignore either. Seo Sanghyeon From dinov at exchange.microsoft.com Thu Apr 6 19:01:05 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 6 Apr 2006 10:01:05 -0700 Subject: [IronPython] base64 module In-Reply-To: <5b0248170604052245m75def21et8dc410151082f732@mail.gmail.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E0252B3FA@df-foxhound-msg.exchange.corp.microsoft.com> Well, CPython at least still enforces the padding, even if it's ignoring the invalid characters. Here's Seo's repro 'simplified' to go straight to binascii (just to get to the root API): >>> import binascii >>> binascii.a2b_base64('%') '' And then sending a valid character, invalid padding: >>> binascii.a2b_base64('A') Traceback (most recent call last): File "", line 1, in ? binascii.Error: Incorrect padding and then throwing in random invalid characters, and CPython ignores the invalid characters: >>> binascii.a2b_base64('ABC=') '\x00\x10' >>> binascii.a2b_base64('%%ABC=') '\x00\x10' >>> binascii.a2b_base64('%%ABC=%!@##') '\x00\x10' >>> binascii.a2b_base64('%%ABC=%!@##*#*()') '\x00\x10' The documentation for binascii.a2b_base64 doesn't specify if it throws for anything either. I would suspect that there's a reason why CPython is ignoring the invalid characters here. If this is the expected behavior then I'm happy to make IronPython match this. And at the very least we HAVE to fix the exception that gets thrown - I'm with Seo that it should be a ValueError but line between ValueError and TypeError is blurry at times anyway, and TypeError is what's documented. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sanghyeon Seo Sent: Wednesday, April 05, 2006 10:45 PM To: python-dev at python.org; users at lists.ironpython.com Subject: [IronPython] base64 module Hello, base64 module documentation for b64decode function says, "TypeError is raised if s were incorrectly padded or if there are non-alphabet characters present in the string." But this doesn't seem to be the case. Testcase: import base64 base64.b64decode('%') Since % is a non-alphabet character, this should raise TypeError (btw, shouldn't this be ValueError instead?), but Python 2.4.3 silently ignores. I found this while experimenting with IronPython. IronPython 1.0 Beta 5 gives: Traceback (most recent call last): File base64, line unknown, in b64decode SystemError: cannot decode byte: '%' It's not TypeError, but it doesn't silently ignore either. Seo Sanghyeon _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From mailinglist.account at gmail.com Thu Apr 6 22:59:01 2006 From: mailinglist.account at gmail.com (Anthony Tarlano) Date: Thu, 6 Apr 2006 22:59:01 +0200 Subject: [IronPython] Bug: module ImportError exception not being raised Message-ID: Hi, I found that IronPython Beta 5 is not raising ImportError and just going into a livelock loop when there is a circular import between two modules. Here is the test case where you'll see CPython returning an ImportError exception and IronPython spining DELL# ls a.py b.py DELL# cat a.py from b import BClass class AClass: pass DELL# cat b.py from a import AClass class BClass: pass DELL# python a.py Traceback (most recent call last): File "a.py", line 1, in ? from b import BClass File "c:\usr\home\tony\ipbug\b.py", line 1, in ? from a import AClass File "c:\usr\home\tony\ipbug\a.py", line 1, in ? from b import BClass ImportError: cannot import name BClass DELL# IronPythonConsole a.py <----------- This command livelocks and never returns Regards, Anthony From dinov at exchange.microsoft.com Fri Apr 7 00:03:45 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 6 Apr 2006 15:03:45 -0700 Subject: [IronPython] Bug: module ImportError exception not being raised In-Reply-To: Message-ID: <4039D552ADAB094BB1EA670F3E96214E0252B83E@df-foxhound-msg.exchange.corp.microsoft.com> Thanks for the bug report, we've got this one filed and should get it fixed for beta 6. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Anthony Tarlano Sent: Thursday, April 06, 2006 1:59 PM To: Discussion of IronPython Subject: [IronPython] Bug: module ImportError exception not being raised Hi, I found that IronPython Beta 5 is not raising ImportError and just going into a livelock loop when there is a circular import between two modules. Here is the test case where you'll see CPython returning an ImportError exception and IronPython spining DELL# ls a.py b.py DELL# cat a.py from b import BClass class AClass: pass DELL# cat b.py from a import AClass class BClass: pass DELL# python a.py Traceback (most recent call last): File "a.py", line 1, in ? from b import BClass File "c:\usr\home\tony\ipbug\b.py", line 1, in ? from a import AClass File "c:\usr\home\tony\ipbug\a.py", line 1, in ? from b import BClass ImportError: cannot import name BClass DELL# IronPythonConsole a.py <----------- This command livelocks and never returns Regards, Anthony _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From joesox at gmail.com Fri Apr 7 00:38:34 2006 From: joesox at gmail.com (JoeSox) Date: Thu, 6 Apr 2006 15:38:34 -0700 Subject: [IronPython] Dict methods Message-ID: <785694cd0604061538q20324459p53b830762436081e@mail.gmail.com> Is there any easy method to use to add a value to an IronPython.Runtime.Dict as seen in the Python code below? fw_edges[arg1_uid].append(fw_edge) where IronPython code I am using: Dict fw_edges = new Dict(); //eg.= {20: [22], 12: [14], 5: [7], 29: [31]} int arg1_uid; int fw_edge; I may be over looking something but I couldn't find a Dict method that could do the .append to the values already established. Thanks -- Joseph From dinov at exchange.microsoft.com Fri Apr 7 01:07:50 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 6 Apr 2006 16:07:50 -0700 Subject: [IronPython] Dict methods In-Reply-To: <785694cd0604061538q20324459p53b830762436081e@mail.gmail.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E025BA870@df-foxhound-msg.exchange.corp.microsoft.com> If I understand correctly you've got a Dict w/ integer keys and a list of values.. You'll need to cast the result to a List and then do the append: ((List)fw_edges[arg1_uid]).append(fw_edge); But that will throw if you don't have a real List (no duck typing allowed). If you wanted to make that work (anything w/ an append method can be called) you could do something like: Ops.Call(Ops.GetAttr(Ops.GetIndex(fw_edges, arg1_uid), SymbolId.Append), fw_edge); Not sure if we have SymbolId.Append baked into the system though... (instead you could do SymbolTable.SymbolToId("append")). The more C# way to do this would be to use generics, such that you do: myDict = new Dictionary(); then you can do: myDict[arg1_uid].append(...) Note you could expose this dictionary out to Python code and it could use it, but it wouldn't be as ideal of an experience as giving the Python developer the real dict. If you wanted to start getting really crazy you could do: [PythonType(typeof(Dict))] class MyDict : Dictionary{ } And then your dictionary would just about appear to be a normal dictionary ,but the user could only ever index off of ints and store lists. Just giving you some options :) Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of JoeSox Sent: Thursday, April 06, 2006 3:39 PM To: Discussion of IronPython Subject: [IronPython] Dict methods Is there any easy method to use to add a value to an IronPython.Runtime.Dict as seen in the Python code below? fw_edges[arg1_uid].append(fw_edge) where IronPython code I am using: Dict fw_edges = new Dict(); //eg.= {20: [22], 12: [14], 5: [7], 29: [31]} int arg1_uid; int fw_edge; I may be over looking something but I couldn't find a Dict method that could do the .append to the values already established. Thanks -- Joseph _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From joesox at gmail.com Fri Apr 7 03:20:32 2006 From: joesox at gmail.com (JoeSox) Date: Thu, 6 Apr 2006 18:20:32 -0700 Subject: [IronPython] Dict methods In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E025BA870@df-foxhound-msg.exchange.corp.microsoft.com> References: <785694cd0604061538q20324459p53b830762436081e@mail.gmail.com> <4039D552ADAB094BB1EA670F3E96214E025BA870@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <785694cd0604061820t5dccb1fds9eb6888c06609ae2@mail.gmail.com> On 4/6/06, Dino Viehland wrote: > If I understand correctly you've got a Dict w/ integer keys and a list of values.. > > You'll need to cast the result to a List and then do the append: > > ((List)fw_edges[arg1_uid]).append(fw_edge); > > But that will throw if you don't have a real List (no duck typing allowed). If you wanted to make that work (anything w/ an append method can be called) you could do something like: > > Ops.Call(Ops.GetAttr(Ops.GetIndex(fw_edges, arg1_uid), SymbolId.Append), fw_edge); > I was wondering if Ops could help me out, I didn't have enough time to test it though before I posted my question. > Not sure if we have SymbolId.Append baked into the system though... (instead you could do SymbolTable.SymbolToId("append")). > > > The more C# way to do this would be to use generics, such that you do: > > myDict = new Dictionary(); > > then you can do: > > myDict[arg1_uid].append(...) For what I am doing, it looks like this may be the easiest solution. I need to make sometime and test this in my project. > Note you could expose this dictionary out to Python code and it could use it, but it wouldn't be as ideal of an experience as giving the Python developer the real dict. If you wanted to start getting really crazy you could do: > > [PythonType(typeof(Dict))] > class MyDict : Dictionary{ > } > > And then your dictionary would just about appear to be a normal dictionary ,but the user could only ever index off of ints and store lists. > Now that is interesting. At first, I was playing around with System.Object and then decided to use int. It just seems that runtime might be slower if I used objects and I would possible need GetTypes() at some point. I don't know at this point, just thinking out loud here. But maybe your custom MyDict example may be best. I need some time to think this thru. > Just giving you some options :) Greatly appreciated! -- Joseph From ernsnat at iit.edu Fri Apr 7 04:36:59 2006 From: ernsnat at iit.edu (Nathan R. Ernst) Date: Thu, 6 Apr 2006 21:36:59 -0500 Subject: [IronPython] Metaclass Error Message-ID: <20060407023712.C99871BB50@che.dreamhost.com> With the following (contrived) metaclass sample, I get a NotImplementedError on the indicated line. It appears to be due to IPythonContainer interface members being unimplemented in IronPython.Runtime.ReflectedType. I've attached the .Net stack separately as it was a little ugly. #######Begin Code Block 1 ####### #!/usr/bin/env python class DataType(type): def __init__(cls, name, bases, dct): dct = dict([(k, cls.make_prop(cls, k, v)) for k, v in dct.iteritems()]) type.__init__(cls, name, bases, dct) def make_prop(cls, name, type, read_only=False): prop_name = '_%s__%s' % (cls.__name__, name) def setter(self, __x): setattr(self, prop_name, type(__x)) def getter(self): return getattr(self, prop_name) if read_only: ## Error occurs here. return property(getter) else: return property(getter, setter) class Test(object): __metaclass__ = DataType foo = str bar = int t = Test() t.foo = 'Hello World' t.bar = 42 print '%s: %d' % (t.foo, t.bar) #######End Code Block 1 ####### IronPython stack: File .\metatest.py, line 23, in Initialize File .\metatest.py, line 6, in __init__ File .\metatest.py, line 18, in make_prop NotImplementedError: The method or operation is not implemented. CPython output: Hello World: 42 if I comment out the "if read_only.else" lines yielding the second code block, the code works. #######Begin Code Block 2 ####### #!/usr/bin/env python class DataType(type): def __init__(cls, name, bases, dct): dct = dict([(k, cls.make_prop(cls, k, v)) for k, v in dct.iteritems()]) type.__init__(cls, name, bases, dct) def make_prop(cls, name, type, read_only=False): prop_name = '_%s__%s' % (cls.__name__, name) def setter(self, __x): setattr(self, prop_name, type(__x)) def getter(self): return getattr(self, prop_name) return property(getter, setter) class Test(object): __metaclass__ = DataType foo = str bar = int t = Test() t.foo = 'Hello World' t.bar = 42 print '%s: %d' % (t.foo, t.bar) #######End Code Block 2####### Output: Hello World: 42 I've not yet had a chance to take a crack at a patch, but I wanted to bring this up as soon as possible. Thanks, as always, for all your hard work, guys. -Nathan Ernst -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: .Net Stack.txt URL: From dinov at exchange.microsoft.com Fri Apr 7 17:58:41 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 7 Apr 2006 08:58:41 -0700 Subject: [IronPython] Metaclass Error In-Reply-To: <20060407023712.C99871BB50@che.dreamhost.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E025BAB9A@df-foxhound-msg.exchange.corp.microsoft.com> Thanks for the bug report. It actually appears to be a bug in our method call logic, and is definitely and interesting corner case. In this case we think make_prop is a method on the class DataType and we think when you call it with cls.(...) that we should add cls in as the first instance parameter (which is quite wrong). Therefore your arguments are shifted over by one, and read_only is a type (which when you check to see if it's true throws not-implemented for it's length). One work around that'll make this work in both CPython and IronPython is to explicitly declare make_prop static: @staticmethod def make_prop(cls, name, type, read_only=False): prop_name = '_%s__%s' % (cls.__name__, name) We should be able to get this one fixed for beta 6. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nathan R. Ernst Sent: Thursday, April 06, 2006 7:37 PM To: users at lists.ironpython.com Subject: [IronPython] Metaclass Error With the following (contrived) metaclass sample, I get a NotImplementedError on the indicated line. It appears to be due to IPythonContainer interface members being unimplemented in IronPython.Runtime.ReflectedType. I've attached the .Net stack separately as it was a little ugly. #######Begin Code Block 1 ####### #!/usr/bin/env python class DataType(type): def __init__(cls, name, bases, dct): dct = dict([(k, cls.make_prop(cls, k, v)) for k, v in dct.iteritems()]) type.__init__(cls, name, bases, dct) def make_prop(cls, name, type, read_only=False): prop_name = '_%s__%s' % (cls.__name__, name) def setter(self, __x): setattr(self, prop_name, type(__x)) def getter(self): return getattr(self, prop_name) if read_only: ## Error occurs here. return property(getter) else: return property(getter, setter) class Test(object): __metaclass__ = DataType foo = str bar = int t = Test() t.foo = 'Hello World' t.bar = 42 print '%s: %d' % (t.foo, t.bar) #######End Code Block 1 ####### IronPython stack: File ...\metatest.py, line 23, in Initialize File ...\metatest.py, line 6, in __init__ File ...\metatest.py, line 18, in make_prop NotImplementedError: The method or operation is not implemented. CPython output: Hello World: 42 if I comment out the "if read_only...else" lines yielding the second code block, the code works. #######Begin Code Block 2 ####### #!/usr/bin/env python class DataType(type): def __init__(cls, name, bases, dct): dct = dict([(k, cls.make_prop(cls, k, v)) for k, v in dct.iteritems()]) type.__init__(cls, name, bases, dct) def make_prop(cls, name, type, read_only=False): prop_name = '_%s__%s' % (cls.__name__, name) def setter(self, __x): setattr(self, prop_name, type(__x)) def getter(self): return getattr(self, prop_name) return property(getter, setter) class Test(object): __metaclass__ = DataType foo = str bar = int t = Test() t.foo = 'Hello World' t.bar = 42 print '%s: %d' % (t.foo, t.bar) #######End Code Block 2####### Output: Hello World: 42 I've not yet had a chance to take a crack at a patch, but I wanted to bring this up as soon as possible. Thanks, as always, for all your hard work, guys. -Nathan Ernst -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrzej.krzywda at resolversystems.com Tue Apr 11 11:36:39 2006 From: andrzej.krzywda at resolversystems.com (Andrzej Krzywda) Date: Tue, 11 Apr 2006 10:36:39 +0100 Subject: [IronPython] re module Message-ID: <443B78A7.3060701@resolversystems.com> Hi, There seems to be a different behaviour in the re module... Python: >>> import re >>> re.match("a[bcd]*b", "abcbd").group(1) Traceback (most recent call last): File "", line 1, in ? IndexError: no such group Iron Python (Beta5): >>> import re >>> re.match("a[bcd]*b", "abcbd").group(1) '' -- Andrzej From mailinglist.account at gmail.com Tue Apr 11 17:52:46 2006 From: mailinglist.account at gmail.com (Anthony Tarlano) Date: Tue, 11 Apr 2006 17:52:46 +0200 Subject: [IronPython] Adding a namespace to a python dll Message-ID: Hi, The question is whether anyone can tell me how to add a namespace to a PE file that was created from a python file using the PythonCompiler? I used the PythonCompiler from IronPython.Hosting to create a DLL assembly, but after adding a reference to the file and attempting to use the using namespace directive from C# to access the classes of the DLL all I get is an error Hosting.cs(3,7): error CS0138: A using namespace directive can only be applied to namespaces; 'service' is a type not a namespace I used the .NET reflector to inspect the PE and sure enough there doesn't seem to be a namespace or more specifically it seems to be a zero length string. tia, Anthony From dinov at exchange.microsoft.com Tue Apr 11 17:55:25 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Tue, 11 Apr 2006 08:55:25 -0700 Subject: [IronPython] re module In-Reply-To: <443B78A7.3060701@resolversystems.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E0267B823@df-foxhound-msg.exchange.corp.microsoft.com> Thanks for the bug report, I've got it filed in our bug database. My guess is that we'll be able to get this fixed for beta 6. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Andrzej Krzywda Sent: Tuesday, April 11, 2006 2:37 AM To: users at lists.ironpython.com Subject: [IronPython] re module Hi, There seems to be a different behaviour in the re module... Python: >>> import re >>> re.match("a[bcd]*b", "abcbd").group(1) Traceback (most recent call last): File "", line 1, in ? IndexError: no such group Iron Python (Beta5): >>> import re >>> re.match("a[bcd]*b", "abcbd").group(1) '' -- Andrzej _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Tue Apr 11 17:58:21 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Tue, 11 Apr 2006 08:58:21 -0700 Subject: [IronPython] Adding a namespace to a python dll In-Reply-To: Message-ID: <4039D552ADAB094BB1EA670F3E96214E0267B82A@df-foxhound-msg.exchange.corp.microsoft.com> Currently there's no way that you can do this. This comes back to the old static compilation problem which we don't yet support (we're a CLS consumer currently, not a CLS producer). If you'd like to interop w/ C# code the best way to do this today would be via interfaces or inheritance from classes defined in C#, and then have the Python code call into the C# code to give C# code objects. Alternately you can use the hosting APIs to create Python objects from C#. This is something that we'd like to provide in the future, but the odds are currently in the favor of this shipping in v1.1 rather than v1.0. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Anthony Tarlano Sent: Tuesday, April 11, 2006 8:53 AM To: Discussion of IronPython Subject: [IronPython] Adding a namespace to a python dll Hi, The question is whether anyone can tell me how to add a namespace to a PE file that was created from a python file using the PythonCompiler? I used the PythonCompiler from IronPython.Hosting to create a DLL assembly, but after adding a reference to the file and attempting to use the using namespace directive from C# to access the classes of the DLL all I get is an error Hosting.cs(3,7): error CS0138: A using namespace directive can only be applied to namespaces; 'service' is a type not a namespace I used the .NET reflector to inspect the PE and sure enough there doesn't seem to be a namespace or more specifically it seems to be a zero length string. tia, Anthony _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From riltim at gmail.com Tue Apr 11 21:15:59 2006 From: riltim at gmail.com (Tim Riley) Date: Tue, 11 Apr 2006 15:15:59 -0400 Subject: [IronPython] Strange Embedding Questions Message-ID: I have an application that I am working on which basically will provide IronPython as a scripting language for AutoCAD. I have a command now that will allow me to select an external python file and run it in AutoCAD, manipulating objects and such. This works fine for testing purposes but in order to release this as a tool that people will use for production purposes I need to develop some sort of loading mechanism that will allow me to do something like load 12 python files at once and call them as needed instead of having an Open File Dialog box pop up every time a user wants to run a script. My next issue which is somewhat coupled with the first. In AutoCAD I would develop a custom command in C# using attributes like this: [CommandMethod("pyfile", CommandFlags.Transparent)] public void pythonfile() { // Create a new instance of PythonEngine and set variables. PythonEngine engine = new PythonEngine(); engine.AddToPath(Environment.CurrentDirectory); // Send Stdout and Stderr to the AutoCAD command line. engine.SetStdout(new AcadCommandLine()); engine.SetVariable("null", null); // Display an OpenFileDialog and run the script. OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Python files (*.py)|*.py|All files (*.*)|*.*" ; ofd.ShowDialog(); // Run the file selected by the open file dialog box. engine.RunFile(ofd.FileName); } Basically I need to come up with some method of defining that CommandMethod Attribute from python file. I'm not necessarily concerned how ugly of a hack it will be but I need a method of defining custom commands from an external file. Anyone have any thoughts/ideas on this. I'm not necessarily looking for a full code solution, however some pointer would be extremely helpful. Thanks for reading, Tim Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Tue Apr 11 21:56:15 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Tue, 11 Apr 2006 12:56:15 -0700 Subject: [IronPython] Strange Embedding Questions In-Reply-To: Message-ID: <4039D552ADAB094BB1EA670F3E96214E0267BB26@df-foxhound-msg.exchange.corp.microsoft.com> You should be able to set Multiselect on the FileOpenDialog to enable choosing of more than one file (although that may not be exactly what you're wanting). Unfortunately we don't have a way to define the CommandMethod from Python because we don't yet support static compilation & custom attributes (but it's starting to seem like it's one of our most popular feature requests). What you might be able to do is either compile a wrapper assembly on the fly per-py file that knows about the .py file that the user wants (I'm assuming AutoCAD uses reflection to discover the command methods in an assembly and you can't instantiate new instances of the class w/ CommandMethod w/ different filenames - which would seem like the easiest solution). Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Tim Riley Sent: Tuesday, April 11, 2006 12:16 PM To: Discussion of IronPython Subject: [IronPython] Strange Embedding Questions I have an application that I am working on which basically will provide IronPython as a scripting language for AutoCAD. I have a command now that will allow me to select an external python file and run it in AutoCAD, manipulating objects and such. This works fine for testing purposes but in order to release this as a tool that people will use for production purposes I need to develop some sort of loading mechanism that will allow me to do something like load 12 python files at once and call them as needed instead of having an Open File Dialog box pop up every time a user wants to run a script. My next issue which is somewhat coupled with the first. In AutoCAD I would develop a custom command in C# using attributes like this: [CommandMethod("pyfile", CommandFlags.Transparent)] public void pythonfile() { // Create a new instance of PythonEngine and set variables. PythonEngine engine = new PythonEngine(); engine.AddToPath(Environment.CurrentDirectory ); // Send Stdout and Stderr to the AutoCAD command line. engine.SetStdout(new AcadCommandLine()); engine.SetVariable("null", null); // Display an OpenFileDialog and run the script. OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Python files (*.py)|*.py|All files (*.*)|*.*" ; ofd.ShowDialog(); // Run the file selected by the open file dialog box. engine.RunFile(ofd.FileName); } Basically I need to come up with some method of defining that CommandMethod Attribute from python file. I'm not necessarily concerned how ugly of a hack it will be but I need a method of defining custom commands from an external file. Anyone have any thoughts/ideas on this. I'm not necessarily looking for a full code solution, however some pointer would be extremely helpful. Thanks for reading, Tim Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Wed Apr 12 00:49:40 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Tue, 11 Apr 2006 15:49:40 -0700 Subject: [IronPython] Bug: module ImportError exception not being raised In-Reply-To: Message-ID: <4039D552ADAB094BB1EA670F3E96214E0267BD67@df-foxhound-msg.exchange.corp.microsoft.com> I've just got around to looking at this, and the repro isn't working for me on beta 5. I've created a.py and b.py: a.py: from b import BClass class AClass: pass b.py: from a import AClass class BClass: pass and then I get: IronPython 1.0.2280 (Beta) on .NET 2.0.50727.32 Copyright (c) Microsoft Corporation. All rights reserved. >>> import a Traceback (most recent call last): File , line 0, in input##0 File , line 0, in __import__##4 File F:\Product\IronPython\IronPython\Experimental\a.py, line 1, in Initialize File , line 0, in __import__##4 File F:\Product\IronPython\IronPython\Experimental\b.py, line 1, in Initialize ImportError: cannot import AClass from a And ditto for import b: IronPython 1.0.2291 (Beta) on .NET 2.0.50727.32 Copyright (c) Microsoft Corporation. All rights reserved. >>> import b Traceback (most recent call last): File , line 0, in input##0 File , line 0, in __import__##4 File F:\Product\IronPython\IronPython\Experimental\b.py, line 1, in Initialize File , line 0, in __import__##4 File F:\Product\IronPython\IronPython\Experimental\a.py, line 1, in Initialize ImportError: cannot import BClass from b I'm wondering if this could be a Mono specific bug. Could you try one thing and give me the result, start IronPythonConsole.exe w/ -X:ExceptionDetail command line option. Then after you start spinning hit Ctrl-C ? That should give you a nice full stack trace of where we were when we were spinning, and if we're lucky we can deduce what's going on from that. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Anthony Tarlano Sent: Thursday, April 06, 2006 1:59 PM To: Discussion of IronPython Subject: [IronPython] Bug: module ImportError exception not being raised Hi, I found that IronPython Beta 5 is not raising ImportError and just going into a livelock loop when there is a circular import between two modules. Here is the test case where you'll see CPython returning an ImportError exception and IronPython spining DELL# ls a.py b.py DELL# cat a.py from b import BClass class AClass: pass DELL# cat b.py from a import AClass class BClass: pass DELL# python a.py Traceback (most recent call last): File "a.py", line 1, in ? from b import BClass File "c:\usr\home\tony\ipbug\b.py", line 1, in ? from a import AClass File "c:\usr\home\tony\ipbug\a.py", line 1, in ? from b import BClass ImportError: cannot import name BClass DELL# IronPythonConsole a.py <----------- This command livelocks and never returns Regards, Anthony _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From mailinglist.account at gmail.com Wed Apr 12 13:28:36 2006 From: mailinglist.account at gmail.com (Anthony Tarlano) Date: Wed, 12 Apr 2006 13:28:36 +0200 Subject: [IronPython] Bug: module ImportError exception not being raised In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E0267BD67@df-foxhound-msg.exchange.corp.microsoft.com> References: <4039D552ADAB094BB1EA670F3E96214E0267BD67@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: Dino, I just tried to reproduce the bug here at work and like you I was unable. The original behavior and test was done on my home PC (Windows Home Edition), so I will have to check later and get back to you. Anthony On 4/12/06, Dino Viehland wrote: > I've just got around to looking at this, and the repro isn't working for me on beta 5. I've created a.py and b.py: > > a.py: > from b import BClass > > class AClass: > pass > > b.py: > from a import AClass > > class BClass: > pass > > > and then I get: > > IronPython 1.0.2280 (Beta) on .NET 2.0.50727.32 > Copyright (c) Microsoft Corporation. All rights reserved. > >>> import a > Traceback (most recent call last): > File , line 0, in input##0 > File , line 0, in __import__##4 > File F:\Product\IronPython\IronPython\Experimental\a.py, line 1, in Initialize > File , line 0, in __import__##4 > File F:\Product\IronPython\IronPython\Experimental\b.py, line 1, in Initialize > ImportError: cannot import AClass from a > > And ditto for import b: > > IronPython 1.0.2291 (Beta) on .NET 2.0.50727.32 > Copyright (c) Microsoft Corporation. All rights reserved. > >>> import b > Traceback (most recent call last): > File , line 0, in input##0 > File , line 0, in __import__##4 > File F:\Product\IronPython\IronPython\Experimental\b.py, line 1, in Initialize > File , line 0, in __import__##4 > File F:\Product\IronPython\IronPython\Experimental\a.py, line 1, in Initialize > ImportError: cannot import BClass from b > > > I'm wondering if this could be a Mono specific bug. Could you try one thing and give me the result, start IronPythonConsole.exe w/ -X:ExceptionDetail command line option. > > Then after you start spinning hit Ctrl-C ? That should give you a nice full stack trace of where we were when we were spinning, and if we're lucky we can deduce what's going on from that. > > > > Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Anthony Tarlano > Sent: Thursday, April 06, 2006 1:59 PM > To: Discussion of IronPython > Subject: [IronPython] Bug: module ImportError exception not being raised > > Hi, > > I found that IronPython Beta 5 is not raising ImportError and just > going into a livelock loop when there is a circular import between two > modules. > > Here is the test case where you'll see CPython returning an > ImportError exception and IronPython spining > > DELL# ls > a.py b.py > DELL# cat a.py > from b import BClass > > class AClass: > pass > DELL# cat b.py > from a import AClass > > class BClass: > pass > DELL# python a.py > Traceback (most recent call last): > File "a.py", line 1, in ? > from b import BClass > File "c:\usr\home\tony\ipbug\b.py", line 1, in ? > from a import AClass > File "c:\usr\home\tony\ipbug\a.py", line 1, in ? > from b import BClass > ImportError: cannot import name BClass > DELL# IronPythonConsole a.py <----------- This command > livelocks and never returns > > > Regards, > > Anthony > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From asimj at exchange.microsoft.com Thu Apr 13 00:53:32 2006 From: asimj at exchange.microsoft.com (Asim Jalis) Date: Wed, 12 Apr 2006 15:53:32 -0700 Subject: [IronPython] IronPython 1.0 Beta 5 Message-ID: <1421F7433DA4144597E8578016CEE5EF01A491C2@df-foxhound-msg.exchange.corp.microsoft.com> Yes. The perf improvement is great. I compared IronPython with Perl and for tasks over 10 seconds, IronPython did significantly better than Perl. However, for short and quick tasks Perl and CPython come out ahead because of their faster start-up times. For example, printing "hello world" takes 0.15 seconds in Perl and 3.31 seconds in IronPython. Is the start-up time something that might go down in future releases? Asim -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Anthony Tarlano Sent: Friday, March 31, 2006 2:07 AM To: Discussion of IronPython Subject: Re: [IronPython] IronPython 1.0 Beta 5 Dino, Great job on improving the performance!!!! IronPython is now faster then CPython running overhead.py After Beta 5: ========= CPC220# python.net overhead.py LOOP TIME: 0.460693359375 THREAD TIME: 0.590881347656 CPC220# IronPythonConsole overhead.py LOOP TIME: 0.460670471191 THREAD TIME: 0.590873718262 ---------------------------------------------------------- # overhead.py import time TIMES = 100000 threads = list() def stringops(): for n in xrange(TIMES): s = "Mary had a little lamb" s = s.upper() s = "Mary had a little lamb" s = s.lower() s = "Mary had a little lamb" s = s.replace('a','A') def scheduler(): for n in xrange(TIMES): for thread in threads: thread.next() def upper(): while 1: s = "Mary had a little lamb" s = s.upper() yield None def lower(): while 1: s = "Mary had a little lamb" s = s.lower() yield None def replace(): while 1: s = "Mary had a little lamb" s = s.replace('a','A') yield None if __name__=='__main__': start = time.clock() stringops() looptime = time.clock()-start print "LOOP TIME:", looptime threads.append(upper()) threads.append(lower()) threads.append(replace()) start = time.clock() scheduler() threadtime = time.clock()-start print "THREAD TIME:", threadtime On 3/31/06, Dino Viehland wrote: > > > > Hello IronPython Community, > > > > We have just released IronPython 1.0 Beta 5. This release focuses primarily > on improving IronPython's performance. In this area we've reduced working > set and startup type by optimizing methods on-demand, improved the speed of > attribute access, reduced the overhead in many basic operations (e.g. > equality checks and uninitialized checks for local variables), and done > other various fine tuning. As usual there are also a good number of bug > fixes (primarily focused on community reported bugs). There was also one > significant API change in the .NET <-> Python interoperability area: > > > > If we have the following definitions: > > > > public class Foo { > > public void Bar(int arg) {} > > public void Bar(int arg) {} > > } > > > > We can call the non-generic version with any of: > > foo.Bar(1) > > foo.Bar.__overloads__[int](1) > > > > And the generic one with any of: > > foo.Bar[str](1) > > foo.Bar.__overloads__[int][str](1) > > foo.Bar[str].__overloads__[int](1) > > > > This is different from previous versions of IronPython where indexing was > used to provide access to generic methods. > > > > A more complete list of changes follows at the end. > > > > You can download the release from: > http://www.microsoft.com/downloads/details.aspx?FamilyID=e4058d5f-49ec-47cb-899e-c4f781e6648f&displaylang=en > > > > We'd like to thank everyone in the community for your bug reports and > suggestions that helped make this a better release: Aaronm, Anthony Tarlano, > Eugene Rosenzweig, Shigeru Hemmi, JoeSox, John Platt, Klaus M?ller, Lewis > Franklin, Pete Sheill, Rusty Deschenes, and Sanghyeon Seo. > > > > > > Thanks and keep in touch, > > The IronPython Team > > > > > > More complete list of changes and bug fixes: > > ============================================ > > ReflectOptimize methods on-demand > > ReflectOptimize hasattr/getattr/setattr and other context aware methods > > Improve BigInteger parsing performance > > abs(True) and abs(False) fixed to match CPython behavior > > os('stat') sets file modes properly now > > Bugfix: Setting variables in nt.environ doesn't propagate to environment > > Bugfix: Improve constructing files from streams > > ReflectOptimizer inlines type checks for non-convertible types > (ICallerContext & UserType) > > Optimize uses of Ops.IsTrue(Ops.Equal(... )) to Ops.EqualRetBool to avoid > boxing & conversions > > Support binding to generic .NET methods and move manual overload resolution > __overloads__ dictionary > > Use data flow analysis to avoid Uninitialized checks where possible in > locals > > Optimize generator.next calls to get good performance > > Bugfix: IronPython CodeDom cannot round trip 2 buttons on a form > > Improve performance of constructing commonly used built-in types > > FunctionEnvironment performance improvements > > Minor tweaks to casting orders > > Avoid TLS where possible in repr > > Bugfix: from __future__ import division doesn't flow into eval in some cases > > Bugfix: hasattr raises > > Bugfix: need to implement nt.startfile > > Bugfix: subclassing Tuple not working > > Bugfix: fix resource definitions in generated files > > Large namespaces use binary search to find attributes > > Bugfix: -i option doesn't go interactive when exception is raised > > SuperConsole now supports Ctrl_C handling as well as basic console > > Bugfix: '%02d' % 12 appends a leading zero > > Attribute access re-written for significant performance gains > > Bugfix: nt module doesn't implement chdir > > ReflectedPackage's delay load all type loads > > Bugfix: atxexit doesn't work > > Bugfix: IP: Cannot use a class from IronPython generated class libraries > > Bugfix: Cannot delete variable referenced in nested scope > > Bugfix: Support special method names (__int__, __pos__, etc...) > > Bugfix: Support for generic & non-generic types of the same name in same > namespace > > Bugfix: __doc__ strings should reflect how we mangle calling conventions > > Bugfix: Update makefiles to include new assembly references > > > > > > > > > > > > Do you want to help develop Dynamic languages on CLR? > (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) > > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Thu Apr 13 01:56:54 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 12 Apr 2006 16:56:54 -0700 Subject: [IronPython] IronPython 1.0 Beta 5 In-Reply-To: <1421F7433DA4144597E8578016CEE5EF01A491C2@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E02711C4F@df-foxhound-msg.exchange.corp.microsoft.com> Unfortunately this is one area where we probably won't get much faster before 1.0 final. We may be able to do some small targeted fixes, but probably nothing revolutionary. But it is an area we would like to improve longer-term (both from the IronPython side of things, as well as the CLR side of things). Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Asim Jalis Sent: Wednesday, April 12, 2006 3:54 PM To: Discussion of IronPython Subject: Re: [IronPython] IronPython 1.0 Beta 5 Yes. The perf improvement is great. I compared IronPython with Perl and for tasks over 10 seconds, IronPython did significantly better than Perl. However, for short and quick tasks Perl and CPython come out ahead because of their faster start-up times. For example, printing "hello world" takes 0.15 seconds in Perl and 3.31 seconds in IronPython. Is the start-up time something that might go down in future releases? Asim -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Anthony Tarlano Sent: Friday, March 31, 2006 2:07 AM To: Discussion of IronPython Subject: Re: [IronPython] IronPython 1.0 Beta 5 Dino, Great job on improving the performance!!!! IronPython is now faster then CPython running overhead.py After Beta 5: ========= CPC220# python.net overhead.py LOOP TIME: 0.460693359375 THREAD TIME: 0.590881347656 CPC220# IronPythonConsole overhead.py LOOP TIME: 0.460670471191 THREAD TIME: 0.590873718262 ---------------------------------------------------------- # overhead.py import time TIMES = 100000 threads = list() def stringops(): for n in xrange(TIMES): s = "Mary had a little lamb" s = s.upper() s = "Mary had a little lamb" s = s.lower() s = "Mary had a little lamb" s = s.replace('a','A') def scheduler(): for n in xrange(TIMES): for thread in threads: thread.next() def upper(): while 1: s = "Mary had a little lamb" s = s.upper() yield None def lower(): while 1: s = "Mary had a little lamb" s = s.lower() yield None def replace(): while 1: s = "Mary had a little lamb" s = s.replace('a','A') yield None if __name__=='__main__': start = time.clock() stringops() looptime = time.clock()-start print "LOOP TIME:", looptime threads.append(upper()) threads.append(lower()) threads.append(replace()) start = time.clock() scheduler() threadtime = time.clock()-start print "THREAD TIME:", threadtime On 3/31/06, Dino Viehland wrote: > > > > Hello IronPython Community, > > > > We have just released IronPython 1.0 Beta 5. This release focuses primarily > on improving IronPython's performance. In this area we've reduced working > set and startup type by optimizing methods on-demand, improved the speed of > attribute access, reduced the overhead in many basic operations (e.g. > equality checks and uninitialized checks for local variables), and done > other various fine tuning. As usual there are also a good number of bug > fixes (primarily focused on community reported bugs). There was also one > significant API change in the .NET <-> Python interoperability area: > > > > If we have the following definitions: > > > > public class Foo { > > public void Bar(int arg) {} > > public void Bar(int arg) {} > > } > > > > We can call the non-generic version with any of: > > foo.Bar(1) > > foo.Bar.__overloads__[int](1) > > > > And the generic one with any of: > > foo.Bar[str](1) > > foo.Bar.__overloads__[int][str](1) > > foo.Bar[str].__overloads__[int](1) > > > > This is different from previous versions of IronPython where indexing was > used to provide access to generic methods. > > > > A more complete list of changes follows at the end. > > > > You can download the release from: > http://www.microsoft.com/downloads/details.aspx?FamilyID=e4058d5f-49ec-47cb-899e-c4f781e6648f&displaylang=en > > > > We'd like to thank everyone in the community for your bug reports and > suggestions that helped make this a better release: Aaronm, Anthony Tarlano, > Eugene Rosenzweig, Shigeru Hemmi, JoeSox, John Platt, Klaus M?ller, Lewis > Franklin, Pete Sheill, Rusty Deschenes, and Sanghyeon Seo. > > > > > > Thanks and keep in touch, > > The IronPython Team > > > > > > More complete list of changes and bug fixes: > > ============================================ > > ReflectOptimize methods on-demand > > ReflectOptimize hasattr/getattr/setattr and other context aware methods > > Improve BigInteger parsing performance > > abs(True) and abs(False) fixed to match CPython behavior > > os('stat') sets file modes properly now > > Bugfix: Setting variables in nt.environ doesn't propagate to environment > > Bugfix: Improve constructing files from streams > > ReflectOptimizer inlines type checks for non-convertible types > (ICallerContext & UserType) > > Optimize uses of Ops.IsTrue(Ops.Equal(... )) to Ops.EqualRetBool to avoid > boxing & conversions > > Support binding to generic .NET methods and move manual overload resolution > __overloads__ dictionary > > Use data flow analysis to avoid Uninitialized checks where possible in > locals > > Optimize generator.next calls to get good performance > > Bugfix: IronPython CodeDom cannot round trip 2 buttons on a form > > Improve performance of constructing commonly used built-in types > > FunctionEnvironment performance improvements > > Minor tweaks to casting orders > > Avoid TLS where possible in repr > > Bugfix: from __future__ import division doesn't flow into eval in some cases > > Bugfix: hasattr raises > > Bugfix: need to implement nt.startfile > > Bugfix: subclassing Tuple not working > > Bugfix: fix resource definitions in generated files > > Large namespaces use binary search to find attributes > > Bugfix: -i option doesn't go interactive when exception is raised > > SuperConsole now supports Ctrl_C handling as well as basic console > > Bugfix: '%02d' % 12 appends a leading zero > > Attribute access re-written for significant performance gains > > Bugfix: nt module doesn't implement chdir > > ReflectedPackage's delay load all type loads > > Bugfix: atxexit doesn't work > > Bugfix: IP: Cannot use a class from IronPython generated class libraries > > Bugfix: Cannot delete variable referenced in nested scope > > Bugfix: Support special method names (__int__, __pos__, etc...) > > Bugfix: Support for generic & non-generic types of the same name in same > namespace > > Bugfix: __doc__ strings should reflect how we mangle calling conventions > > Bugfix: Update makefiles to include new assembly references > > > > > > > > > > > > Do you want to help develop Dynamic languages on CLR? > (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) > > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From sanxiyn at gmail.com Fri Apr 14 17:18:09 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Sat, 15 Apr 2006 00:18:09 +0900 Subject: [IronPython] socket for IronPython update Message-ID: <5b0248170604140818w2525f5f7mba96b8c5c631a8bd@mail.gmail.com> I updated socket.py a bit: http://sparcs.kaist.ac.kr/~tinuviel/fepy/lib/ This version should work with IronPython 1.0 Beta 5. Changes since the last update are: * Error handling: convert SocketException to socket.error * Resolve hostname in connect() * Translate empty string to IPAddress.Any in bind() * Support AF_UNSPEC (and convert 0 to AF_UNSPEC; there are codes passing int directly) Seo Sanghyeon From sanxiyn at gmail.com Sat Apr 15 16:29:12 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Sat, 15 Apr 2006 23:29:12 +0900 Subject: [IronPython] True == 'foo' Message-ID: <5b0248170604150729t24be295bqb7968dd4efdb4fec@mail.gmail.com> >>> True == 'foo' True I guess this bug is related to "False == None" bug already reported? Seo Sanghyeon From sanxiyn at gmail.com Sat Apr 15 17:48:17 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Sun, 16 Apr 2006 00:48:17 +0900 Subject: [IronPython] Namespace pollution Message-ID: <5b0248170604150848n2620b6dfx8e24c1d70467d65a@mail.gmail.com> # test.py one = len('a') >>> import test >>> test.len It seems that builtin function names are inroduced to the module namespace if they are used. This is unlike CPython, where only test.one would be available in the above example. Seo Sanghyeon From dinov at exchange.microsoft.com Sat Apr 15 17:57:30 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Sat, 15 Apr 2006 08:57:30 -0700 Subject: [IronPython] True == 'foo' In-Reply-To: <5b0248170604150729t24be295bqb7968dd4efdb4fec@mail.gmail.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E0279A7EC@df-foxhound-msg.exchange.corp.microsoft.com> That is related - for beta 6 we've actually added a large test set that compares CPython & IronPython results for comparing large numbers of types (and classes pretending to be types) to make sure we get this nailed down, and this appears to be one of the issues we've fixed while doing that. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sanghyeon Seo Sent: Saturday, April 15, 2006 7:29 AM To: Discussion of IronPython Subject: [IronPython] True == 'foo' >>> True == 'foo' True I guess this bug is related to "False == None" bug already reported? Seo Sanghyeon _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Sat Apr 15 18:03:06 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Sat, 15 Apr 2006 09:03:06 -0700 Subject: [IronPython] Namespace pollution In-Reply-To: <5b0248170604150848n2620b6dfx8e24c1d70467d65a@mail.gmail.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E0279A7EE@df-foxhound-msg.exchange.corp.microsoft.com> Thanks for the report, we've actually already got a fix for this for beta 6. There was a bunch of weirdness around these as well - for example you also used to be able to delete the builtins inside of a module. For beta 6 we've cleaned all of that up so you don't see these external to the module unless they've been explicitly assigned to (e.g: one = len('a') len = 'abc' and then if you delete len again external callers will no longer see it. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sanghyeon Seo Sent: Saturday, April 15, 2006 8:48 AM To: Discussion of IronPython Subject: [IronPython] Namespace pollution # test.py one = len('a') >>> import test >>> test.len It seems that builtin function names are inroduced to the module namespace if they are used. This is unlike CPython, where only test.one would be available in the above example. Seo Sanghyeon _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From kristof.wagemans at gmail.com Sun Apr 16 15:02:23 2006 From: kristof.wagemans at gmail.com (Kristof Wagemans) Date: Sun, 16 Apr 2006 15:02:23 +0200 Subject: [IronPython] Are two PythonEngine instances connected? Message-ID: <000001c66156$01789800$0f01a8c0@notebook> I've created two PythonEngine instances and set the Stdout for each instance to its own custom stream class (PythonStream) to capture the output. This stream class takes a delegate to specify the function to receive the response. class Tester { public void Test() { PythonEngine pythonEngine1 = new PythonEngine(); pythonEngine1.SetStdout(new PythonStream(ResponsePythonEngine1)); Console.WriteLine("pythonEngine1.Execute(\"'p1'\") -> "); pythonEngine1.Execute("'p1'"); Console.WriteLine(""); PythonEngine pythonEngine2 = new PythonEngine(); pythonEngine2.SetStdout(new PythonStream(ResponsePythonEngine2)); Console.WriteLine("pythonEngine2.Execute(\"'p2'\") -> "); pythonEngine2.Execute("'p2'"); Console.WriteLine(""); Console.WriteLine("pythonEngine1.Execute(\"'p1'\") -> "); pythonEngine1.Execute("'p1'"); Console.WriteLine(""); Console.ReadLine(); } void ResponsePythonEngine1(string text) { if (!string.IsNullOrEmpty(text.Trim())) { Console.WriteLine(" ResponsePythonEngine1 -> " + text); } } void ResponsePythonEngine2(string text) { if (!string.IsNullOrEmpty(text.Trim())) { Console.WriteLine(" ResponsePythonEngine2 -> " + text); } } } After pythonEngine2 is created I receive the responses from commands executed on pythonEngine1 on the output of pythonEngine2. pythonEngine1.Execute("'p1'") -> ResponsePythonEngine1 -> 'p1' pythonEngine2.Execute("'p2'") -> ResponsePythonEngine2 -> 'p2' pythonEngine1.Execute("'p1'") -> ResponsePythonEngine2 -> 'p1' You can find my test application here: http://users.telenet.be/kristof.wagemans/PythonEngineConnected.zip -------------- next part -------------- An HTML attachment was scrubbed... URL: From joesox at gmail.com Sun Apr 16 17:06:53 2006 From: joesox at gmail.com (JoeSox) Date: Sun, 16 Apr 2006 08:06:53 -0700 Subject: [IronPython] Speed test Message-ID: <785694cd0604160806k31d65c86s8e6cf303852288a0@mail.gmail.com> Am I doing this speed test correctly using the script and process below? I have unpp.py on a usb jumpdrive E ------- #unpp.py import time def unpp(pp): time1=time.clock() toks = pp.strip(' ()\n').split() pred = toks[0] args = ' '.join(toks[1:])[1:-1].split('" "') f,i = map(lambda x:int(x.split('=')[1]),args.pop().split(';')[:2]) time2=time.clock() print pred,args[0],args[1],f,i print time1 print time2 print "-- unpp took",str(round(time2-time1,6)),'seconds. --\n' ---------- ===== I run a test in IDLE Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32 IDLE 1.1.2 ==== No Subprocess ==== >>> import sys >>> sys.path.append('E/') >>> import unpp >>> p=unpp >>> p.unpp('(CapableOf \"red bicycle\" \"pump\" \"f=2;i=1;\")') CapableOf red bicycle pump 2 1 50.3331431788 50.3331713947 -- unpp took 2.8e-005 seconds. -- ===== END of IDLE test 2.8e-005 = 0.000028 ====== I run same test in IronPythonConsole IronPython 1.0.2280 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import sys >>> sys.path.append('E:/') >>> import unpp >>> p=unpp >>> p.unpp('(CapableOf \"red bicycle\" \"pump\" \"f=2;i=1;\")') CapableOf red bicycle pump 2 1 63280770878.0 63280770878.0 -- unpp took 0.046867 seconds. -- ===== END of IronPythonConsole test If I am doing this correctly, there seems to be a big process time difference, does this seem to be correct, or I am missing something or doing the time() incorrectly? Thanks! -- Joseph From gardner at networknow.org Mon Apr 17 01:33:55 2006 From: gardner at networknow.org (Gardner Pomper) Date: Sun, 16 Apr 2006 19:33:55 -0400 Subject: [IronPython] MapPoint COM object? Message-ID: <42d22dbf0604161633le92148fr2421007ed2861370@mail.gmail.com> Hi, I am trying to manipulate mappoint from an IronPython script. I tried to do the COM integration I found in the Tutorial, but it failed. I have copied what I did into this email. Can someone take a look and tell me what I should have done? Thanks! - Gardner C:\Program Files\Microsoft MapPoint>tlbimp mpna82.tlb Microsoft (R) .NET Framework Type Library to Assembly Converter 2.0.50727.42 Copyright (C) Microsoft Corporation. All rights reserved. Type library imported to MapPoint.dll C:\Program Files\Microsoft MapPoint>\IronPython\IronPythonConsole IronPython 1.0.2280 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import clr >>> clr.AddReferenceToFile('MapPoint.dll') Traceback (most recent call last): File , line 0, in input##5 File , line 0, in AddReferenceToFile##6 RuntimeError: Could not add reference to assembly MapPoint.dll -------------- next part -------------- An HTML attachment was scrubbed... URL: From gardner at networknow.org Mon Apr 17 01:33:55 2006 From: gardner at networknow.org (Gardner Pomper) Date: Sun, 16 Apr 2006 19:33:55 -0400 Subject: [IronPython] MapPoint COM object? Message-ID: <42d22dbf0604161633le92148fr2421007ed2861370@mail.gmail.com> Hi, I am trying to manipulate mappoint from an IronPython script. I tried to do the COM integration I found in the Tutorial, but it failed. I have copied what I did into this email. Can someone take a look and tell me what I should have done? Thanks! - Gardner C:\Program Files\Microsoft MapPoint>tlbimp mpna82.tlb Microsoft (R) .NET Framework Type Library to Assembly Converter 2.0.50727.42 Copyright (C) Microsoft Corporation. All rights reserved. Type library imported to MapPoint.dll C:\Program Files\Microsoft MapPoint>\IronPython\IronPythonConsole IronPython 1.0.2280 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import clr >>> clr.AddReferenceToFile('MapPoint.dll') Traceback (most recent call last): File , line 0, in input##5 File , line 0, in AddReferenceToFile##6 RuntimeError: Could not add reference to assembly MapPoint.dll -------------- next part -------------- An HTML attachment was scrubbed... URL: From vincent at visualtrans.de Mon Apr 17 09:41:47 2006 From: vincent at visualtrans.de (Vincent ) Date: Mon, 17 Apr 2006 08:41:47 +0100 Subject: [IronPython] MapPoint COM object? In-Reply-To: <42d22dbf0604161633le92148fr2421007ed2861370@mail.gmail.com> Message-ID: <000001c661f2$6223a180$8402a8c0@VINWEHVAIO> Hi Gardner I also noticed this when going through the COM interop tutorial the other day. You could try using clr.AddReferenceToFileAndPath(r"c:\full\path\to\dll\here\yourdllname.dll") which worked for me. (FYI, a bug has been logged in MS bugdb...) HTH, -- Vincent Wehren ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Gardner Pomper Sent: Monday, April 17, 2006 12:34 AM To: Discussion of IronPython Cc: IronPython List Subject: [IronPython] MapPoint COM object? Hi, I am trying to manipulate mappoint from an IronPython script. I tried to do the COM integration I found in the Tutorial, but it failed. I have copied what I did into this email. Can someone take a look and tell me what I should have done? Thanks! - Gardner C:\Program Files\Microsoft MapPoint>tlbimp mpna82.tlb Microsoft (R) .NET Framework Type Library to Assembly Converter 2.0.50727.42 Copyright (C) Microsoft Corporation. All rights reserved. Type library imported to MapPoint.dll C:\Program Files\Microsoft MapPoint>\IronPython\IronPythonConsole IronPython 1.0.2280 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import clr >>> clr.AddReferenceToFile('MapPoint.dll') Traceback (most recent call last): File , line 0, in input##5 File , line 0, in AddReferenceToFile##6 RuntimeError: Could not add reference to assembly MapPoint.dll From korpse-ironpython at kaydash.za.net Mon Apr 17 12:35:11 2006 From: korpse-ironpython at kaydash.za.net (Jonathan Jacobs) Date: Mon, 17 Apr 2006 12:35:11 +0200 Subject: [IronPython] MapPoint COM object? In-Reply-To: <42d22dbf0604161633le92148fr2421007ed2861370@mail.gmail.com> References: <42d22dbf0604161633le92148fr2421007ed2861370@mail.gmail.com> Message-ID: <44436F5F.4000401@kaydash.za.net> Gardner Pomper wrote: > Hi, > > I am trying to manipulate mappoint from an IronPython script. I tried to > do the COM integration I found in the Tutorial, but it failed. I have > copied what I did into this email. Can someone take a look and tell me > what I should have done? I believe the problem is that your working directory is not in clr.Path (a Python list), which specifies paths in which to search for assemblies. >>> import clr >>> clr.AddReferenceToFile('IconTools.dll') Traceback (most recent call last): File , line 0, in input##6 File , line 0, in AddReferenceToFile##7 RuntimeError: Could not add reference to assembly IconTools.dll >>> import os >>> clr.Path.append(os.getcwd()) >>> clr.AddReferenceToFile('IconTools.dll') >>> import IconTools >>> IconTools >>> HTH -- Jonathan When you meet a master swordsman, show him your sword. When you meet a man who is not a poet, do not show him your poem. -- Rinzai, ninth century Zen master From dans at houmus.org Mon Apr 17 12:38:26 2006 From: dans at houmus.org (Dan Shechter) Date: Mon, 17 Apr 2006 13:38:26 +0300 Subject: [IronPython] COM Interop / Dispose wierdness Message-ID: <003301c6620b$17d73560$424210ac@cartman> Hi, I have a c# class which is a wrapper around the WMF (Windows Media Format) SDK. One of the classes, which wraps the IWMMetadataEditor interface roughly looks like this: namespace WMFSDKWrapper { public class MetadataEditor : IDisposable, IEnumerable { bool isDisposed = false; private IWMMetadataEditor editor; ... public void Flush() { editor.Flush(); } private void Dispose(bool disposing) { if (!isDisposed) { if (disposing) ; // No managed resources to clear up... // Clear up unmanaged resources Flush(); } isDisposed = true; } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } ~MetadataEditor() { Dispose(false); } } } Now, the wrapper (which obviously has more code) works perfectly. I can change a WM file's metadata or query it as I wish. I can call the Flush(), Close() or even Dispose() method directly and they all work fine... i.e.: If I call the Dispose() method "manually" I get: IronPython 1.0.2281 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import wmf >>> m = wmf.MetadataEditor("a.wma") >>> m[wmf.MediaMetadata.Title] '123' >>> m.Dispose() >>> ^Z (IronPythonConsole.exe exits cleanly) The problem I'm getting is that if exit the IronPython console without calling the object's Dispose method beforehand I get Something like this, regardless of what I did with the COM object (i.e., read-only or read-write): IronPython 1.0.2281 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import wmf >>> m = wmf.MetadataEditor("a.wma") >>> m[wmf.MediaMetadata.Title] '123' >>> ^Z Unhandled exception: Traceback (most recent call last): File WMFSDKWrapper, line unknown, in Finalize File WMFSDKWrapper, line unknown, in Dispose File WMFSDKWrapper, line unknown, in Flush File WMFSDKWrapper, line unknown, in Flush TypeError: Unable to cast COM object of type 'System.__ComObject' to interface type 'WMFSDKWrapper.IWMMetadataEditor'. T his operation failed because the QueryInterface call on the COM component for the interface with IID '{96406BD9-2B2B-11D 3-B36B-00C04F6108FF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). Unhandled Exception: System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface ty pe 'WMFSDKWrapper.IWMMetadataEditor'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{96406BD9-2B2B-11D3-B36B-00C04F6108FF}' failed due to the following error: No such interface suppor ted (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). at WMFSDKWrapper.IWMMetadataEditor.Flush() at WMFSDKWrapper.MetadataEditor.Flush() at WMFSDKWrapper.MetadataEditor.Dispose(Boolean disposing) at WMFSDKWrapper.MetadataEditor.Finalize() Any ideas? Shechter. From dinov at exchange.microsoft.com Mon Apr 17 16:57:56 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 17 Apr 2006 07:57:56 -0700 Subject: [IronPython] Are two PythonEngine instances connected? In-Reply-To: <000001c66156$01789800$0f01a8c0@notebook> Message-ID: <4039D552ADAB094BB1EA670F3E96214E0279A958@df-foxhound-msg.exchange.corp.microsoft.com> Yes, right now we unfortunately have some shared state between them. We're not entirely certain where we'll land w/ this for V1 yet - whether we'll attempt to keep them separated entirely, or make it obvious (e.g. a static class) that there's only one engine available. If we end up w/ just one then our isolation story would be app domain isolation. If you've got feedback on which one is better for you (I'm guessing having them be independent) we'd love to hear it. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Kristof Wagemans Sent: Sunday, April 16, 2006 6:02 AM To: users at lists.ironpython.com Subject: [IronPython] Are two PythonEngine instances connected? I've created two PythonEngine instances and set the Stdout for each instance to its own custom stream class (PythonStream) to capture the output. This stream class takes a delegate to specify the function to receive the response. class Tester { public void Test() { PythonEngine pythonEngine1 = new PythonEngine(); pythonEngine1.SetStdout(new PythonStream(ResponsePythonEngine1)); Console.WriteLine("pythonEngine1.Execute(\"'p1'\") -> "); pythonEngine1.Execute("'p1'"); Console.WriteLine(""); PythonEngine pythonEngine2 = new PythonEngine(); pythonEngine2.SetStdout(new PythonStream(ResponsePythonEngine2)); Console.WriteLine("pythonEngine2.Execute(\"'p2'\") -> "); pythonEngine2.Execute("'p2'"); Console.WriteLine(""); Console.WriteLine("pythonEngine1.Execute(\"'p1'\") -> "); pythonEngine1.Execute("'p1'"); Console.WriteLine(""); Console.ReadLine(); } void ResponsePythonEngine1(string text) { if (!string.IsNullOrEmpty(text.Trim())) { Console.WriteLine(" ResponsePythonEngine1 -> " + text); } } void ResponsePythonEngine2(string text) { if (!string.IsNullOrEmpty(text.Trim())) { Console.WriteLine(" ResponsePythonEngine2 -> " + text); } } } After pythonEngine2 is created I receive the responses from commands executed on pythonEngine1 on the output of pythonEngine2. pythonEngine1.Execute("'p1'") -> ResponsePythonEngine1 -> 'p1' pythonEngine2.Execute("'p2'") -> ResponsePythonEngine2 -> 'p2' pythonEngine1.Execute("'p1'") -> ResponsePythonEngine2 -> 'p1' You can find my test application here: http://users.telenet.be/kristof.wagemans/PythonEngineConnected.zip -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Mon Apr 17 17:10:37 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 17 Apr 2006 08:10:37 -0700 Subject: [IronPython] Speed test In-Reply-To: <785694cd0604160806k31d65c86s8e6cf303852288a0@mail.gmail.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E0279A964@df-foxhound-msg.exchange.corp.microsoft.com> IronPython is slower to get things going the first time (because we end up compiling to IL and then JITing the code); it's after that when we really start to shine. The first time you run this we will take longer to execute it, but if you do it a second time we'll report zero. When I run it the first time I get ~.20 seconds, the second time I get 0 seconds - which is just below the precision of the clock. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of JoeSox Sent: Sunday, April 16, 2006 8:07 AM To: Discussion of IronPython Subject: [IronPython] Speed test Am I doing this speed test correctly using the script and process below? I have unpp.py on a usb jumpdrive E ------- #unpp.py import time def unpp(pp): time1=time.clock() toks = pp.strip(' ()\n').split() pred = toks[0] args = ' '.join(toks[1:])[1:-1].split('" "') f,i = map(lambda x:int(x.split('=')[1]),args.pop().split(';')[:2]) time2=time.clock() print pred,args[0],args[1],f,i print time1 print time2 print "-- unpp took",str(round(time2-time1,6)),'seconds. --\n' ---------- ===== I run a test in IDLE Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32 IDLE 1.1.2 ==== No Subprocess ==== >>> import sys >>> sys.path.append('E/') >>> import unpp >>> p=unpp >>> p.unpp('(CapableOf \"red bicycle\" \"pump\" \"f=2;i=1;\")') CapableOf red bicycle pump 2 1 50.3331431788 50.3331713947 -- unpp took 2.8e-005 seconds. -- ===== END of IDLE test 2.8e-005 = 0.000028 ====== I run same test in IronPythonConsole IronPython 1.0.2280 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import sys >>> sys.path.append('E:/') >>> import unpp >>> p=unpp >>> p.unpp('(CapableOf \"red bicycle\" \"pump\" \"f=2;i=1;\")') CapableOf red bicycle pump 2 1 63280770878.0 63280770878.0 -- unpp took 0.046867 seconds. -- ===== END of IronPythonConsole test If I am doing this correctly, there seems to be a big process time difference, does this seem to be correct, or I am missing something or doing the time() incorrectly? Thanks! -- Joseph _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Mon Apr 17 17:23:51 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 17 Apr 2006 08:23:51 -0700 Subject: [IronPython] COM Interop / Dispose wierdness In-Reply-To: <003301c6620b$17d73560$424210ac@cartman> Message-ID: <4039D552ADAB094BB1EA670F3E96214E0279A96B@df-foxhound-msg.exchange.corp.microsoft.com> This could be an order of finalization issue - if you let things shut down entirely then all the finalizers in the system would be eligible to be run at once. But if you dispose of the MetadataEditor by hand anything it depends upon won't have its finalizer run yet. At shutdown time the CLR will run all remaining finalizers and we could be cleaning up in the "wrong" order (although there's really no right order, finalization is non-deterministic). I think you'd need to talk to the WMF SDK team about the issue as they'll understand better their finalization issues (or wrap dispose in a try/catch InvalidCastException block :) ). Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dan Shechter Sent: Monday, April 17, 2006 3:38 AM To: 'Discussion of IronPython' Subject: [IronPython] COM Interop / Dispose wierdness Hi, I have a c# class which is a wrapper around the WMF (Windows Media Format) SDK. One of the classes, which wraps the IWMMetadataEditor interface roughly looks like this: namespace WMFSDKWrapper { public class MetadataEditor : IDisposable, IEnumerable { bool isDisposed = false; private IWMMetadataEditor editor; ... public void Flush() { editor.Flush(); } private void Dispose(bool disposing) { if (!isDisposed) { if (disposing) ; // No managed resources to clear up... // Clear up unmanaged resources Flush(); } isDisposed = true; } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } ~MetadataEditor() { Dispose(false); } } } Now, the wrapper (which obviously has more code) works perfectly. I can change a WM file's metadata or query it as I wish. I can call the Flush(), Close() or even Dispose() method directly and they all work fine... i.e.: If I call the Dispose() method "manually" I get: IronPython 1.0.2281 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import wmf >>> m = wmf.MetadataEditor("a.wma") >>> m[wmf.MediaMetadata.Title] '123' >>> m.Dispose() >>> ^Z (IronPythonConsole.exe exits cleanly) The problem I'm getting is that if exit the IronPython console without calling the object's Dispose method beforehand I get Something like this, regardless of what I did with the COM object (i.e., read-only or read-write): IronPython 1.0.2281 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import wmf >>> m = wmf.MetadataEditor("a.wma") >>> m[wmf.MediaMetadata.Title] '123' >>> ^Z Unhandled exception: Traceback (most recent call last): File WMFSDKWrapper, line unknown, in Finalize File WMFSDKWrapper, line unknown, in Dispose File WMFSDKWrapper, line unknown, in Flush File WMFSDKWrapper, line unknown, in Flush TypeError: Unable to cast COM object of type 'System.__ComObject' to interface type 'WMFSDKWrapper.IWMMetadataEditor'. T his operation failed because the QueryInterface call on the COM component for the interface with IID '{96406BD9-2B2B-11D 3-B36B-00C04F6108FF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). Unhandled Exception: System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface ty pe 'WMFSDKWrapper.IWMMetadataEditor'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{96406BD9-2B2B-11D3-B36B-00C04F6108FF}' failed due to the following error: No such interface suppor ted (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). at WMFSDKWrapper.IWMMetadataEditor.Flush() at WMFSDKWrapper.MetadataEditor.Flush() at WMFSDKWrapper.MetadataEditor.Dispose(Boolean disposing) at WMFSDKWrapper.MetadataEditor.Finalize() Any ideas? Shechter. _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From kristof.wagemans at gmail.com Mon Apr 17 20:40:57 2006 From: kristof.wagemans at gmail.com (Kristof Wagemans) Date: Mon, 17 Apr 2006 20:40:57 +0200 Subject: [IronPython] Are two PythonEngine instances connected? In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E0279A958@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <000601c6624e$78725dd0$0f01a8c0@notebook> I'm thinking of using IronPython as a scripting language inside a future WPF application. (I'm just experimenting; there's nothing planned at the moment.) Here's an example of what I would like to do. I have a data object that's data bound to the user interface. When the user changes a property (or it's changed programmatically) I would like to run a custom script. This script gets a reference (SetVariable) to the changed object. It can now calculate and set a different property on the data object (or on some other object or send an e-mail or whatever). Setting the property can trigger a new script to run while the previous one isn't finished executing yet. The new script should run in a clean environment to exclude unwanted interactions: it could use the same variables or have conflicting functions defined. Is there a way to keep the script environments separated? With a single PythonEngine you also wouldn't have to pay the startup cost each time. This could give unacceptable delays while running the application anyway. I think that some form of sharing is unavoidable. It would still be nice to have separate instances though, maybe one PythonEngine per separate task that the user starts. I would also like to include inside the application an interactive console. I have a prototype working. It doesn't run in a blocking loop anymore: the application's UI keeps running normally. Multiple of these interactive sessions could be opened at the same time. I need the output of each engine to go to the correct console. This is how I stumbled across the problem. In my main window I used the console to create a new instance of the same window (which also contained an instance of my PythonConsole). But all the output of the first console suddenly showed up in the second console, which was a bit surprising. If you can't make the changes to have multiple PythonEngine's running at the same time it would be safest to make it impossible to create them. It wouldn't surprise me if other people run into the same problem if they integrate IronPython into their applications. _____ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland Sent: Monday 17 April 2006 16:58 To: Discussion of IronPython Subject: Re: [IronPython] Are two PythonEngine instances connected? Yes, right now we unfortunately have some shared state between them. We're not entirely certain where we'll land w/ this for V1 yet - whether we'll attempt to keep them separated entirely, or make it obvious (e.g. a static class) that there's only one engine available. If we end up w/ just one then our isolation story would be app domain isolation. If you've got feedback on which one is better for you (I'm guessing having them be independent) we'd love to hear it. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F 0-45DF-8B78-DC1B43134038) _____ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Kristof Wagemans Sent: Sunday, April 16, 2006 6:02 AM To: users at lists.ironpython.com Subject: [IronPython] Are two PythonEngine instances connected? I've created two PythonEngine instances and set the Stdout for each instance to its own custom stream class (PythonStream) to capture the output. This stream class takes a delegate to specify the function to receive the response. class Tester { public void Test() { PythonEngine pythonEngine1 = new PythonEngine(); pythonEngine1.SetStdout(new PythonStream(ResponsePythonEngine1)); Console.WriteLine("pythonEngine1.Execute(\"'p1'\") -> "); pythonEngine1.Execute("'p1'"); Console.WriteLine(""); PythonEngine pythonEngine2 = new PythonEngine(); pythonEngine2.SetStdout(new PythonStream(ResponsePythonEngine2)); Console.WriteLine("pythonEngine2.Execute(\"'p2'\") -> "); pythonEngine2.Execute("'p2'"); Console.WriteLine(""); Console.WriteLine("pythonEngine1.Execute(\"'p1'\") -> "); pythonEngine1.Execute("'p1'"); Console.WriteLine(""); Console.ReadLine(); } void ResponsePythonEngine1(string text) { if (!string.IsNullOrEmpty(text.Trim())) { Console.WriteLine(" ResponsePythonEngine1 -> " + text); } } void ResponsePythonEngine2(string text) { if (!string.IsNullOrEmpty(text.Trim())) { Console.WriteLine(" ResponsePythonEngine2 -> " + text); } } } After pythonEngine2 is created I receive the responses from commands executed on pythonEngine1 on the output of pythonEngine2. pythonEngine1.Execute("'p1'") -> ResponsePythonEngine1 -> 'p1' pythonEngine2.Execute("'p2'") -> ResponsePythonEngine2 -> 'p2' pythonEngine1.Execute("'p1'") -> ResponsePythonEngine2 -> 'p1' You can find my test application here: http://users.telenet.be/kristof.wagemans/PythonEngineConnected.zip -------------- next part -------------- An HTML attachment was scrubbed... URL: From trimbo at gmail.com Mon Apr 17 20:47:35 2006 From: trimbo at gmail.com (Chris Trimble) Date: Mon, 17 Apr 2006 11:47:35 -0700 Subject: [IronPython] Sin and Sqrt performance Message-ID: IP doesn't do much better than CPython when using math.sin and math.sqrt. However, same test in C# dominates (10ms.. as opposed to upwards of 5 seconds in IP or CPy). Am I missing something here? Thanks, - Chris ----------------------------------- import time from math import * def do_timing(f, reps): start = time.time() f(reps) end = time.time() print "%s (%d reps): %f" % (f.__name__, reps, end-start) def py_fpfunc_test(reps): j = 0.0 for i in range(0, reps): j += sin( j ) j += sqrt( j ) j +=2.72392032032; print j def do_all_timing(): do_timing(py_fpfunc_test, 5000000) do_all_timing() print "" From midnightdf at yahoo.com Mon Apr 17 23:42:57 2006 From: midnightdf at yahoo.com (Dave) Date: Mon, 17 Apr 2006 14:42:57 -0700 (PDT) Subject: [IronPython] Sin and Sqrt performance (Chris Trimble) In-Reply-To: Message-ID: <20060417214257.37781.qmail@web51311.mail.yahoo.com> Use xrange instead of range and there should be a pretty good performance improvement;) As is, your for loop creates a list of five million elements. A simple while loop would also do the trick although it's not as clean to look at. Dave users-request at lists.ironpython.com wrote: Send users mailing list submissions to users at lists.ironpython.com To subscribe or unsubscribe via the World Wide Web, visit http://lists.ironpython.com/listinfo.cgi/users-ironpython.com or, via email, send a message with subject or body 'help' to users-request at lists.ironpython.com You can reach the person managing the list at users-owner at lists.ironpython.com When replying, please edit your Subject line so it is more specific than "Re: Contents of users digest..." Today's Topics: 1. Sin and Sqrt performance (Chris Trimble) ---------------------------------------------------------------------- Message: 1 Date: Mon, 17 Apr 2006 11:47:35 -0700 From: "Chris Trimble" Subject: [IronPython] Sin and Sqrt performance To: "Discussion of IronPython" Message-ID: Content-Type: text/plain; charset=ISO-8859-1 IP doesn't do much better than CPython when using math.sin and math.sqrt. However, same test in C# dominates (10ms.. as opposed to upwards of 5 seconds in IP or CPy). Am I missing something here? Thanks, - Chris ----------------------------------- import time from math import * def do_timing(f, reps): start = time.time() f(reps) end = time.time() print "%s (%d reps): %f" % (f.__name__, reps, end-start) def py_fpfunc_test(reps): j = 0.0 for i in range(0, reps): j += sin( j ) j += sqrt( j ) j +=2.72392032032; print j def do_all_timing(): do_timing(py_fpfunc_test, 5000000) do_all_timing() print "" ------------------------------ _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com End of users Digest, Vol 21, Issue 18 ************************************* --------------------------------- How low will we go? Check out Yahoo! Messenger?s low PC-to-Phone call rates. -------------- next part -------------- An HTML attachment was scrubbed... URL: From trimble at pobox.com Mon Apr 17 23:53:14 2006 From: trimble at pobox.com (Chris Trimble) Date: Mon, 17 Apr 2006 14:53:14 -0700 Subject: [IronPython] Sin and Sqrt performance (Chris Trimble) In-Reply-To: <20060417214257.37781.qmail@web51311.mail.yahoo.com> References: <20060417214257.37781.qmail@web51311.mail.yahoo.com> Message-ID: Did you try making the change on your end and see a change? It makes no difference on my end. BTW, I had tried 'while' before making the original post. No difference there either. In fact, range() has better performance than 'while' in CPython for this code! - Chris On 4/17/06, Dave wrote: > Use xrange instead of range and there should be a pretty good performance > improvement;) As is, your for loop creates a list of five million elements. > A simple while loop would also do the trick although it's not as clean to > look at. > > Dave > > users-request at lists.ironpython.com wrote: > Send users mailing list submissions to > users at lists.ironpython.com > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > or, via email, send a message with subject or body 'help' to > users-request at lists.ironpython.com > > You can reach the person managing the list at > users-owner at lists.ironpython.com > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > Today's Topics: > > 1. Sin and Sqrt performance (Chris Trimble) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 17 Apr 2006 11:47:35 -0700 > From: "Chris Trimble" > Subject: [IronPython] Sin and Sqrt performance > To: "Discussion of IronPython" > Message-ID: > > Content-Type: text/plain; charset=ISO-8859-1 > > IP doesn't do much better than CPython when using math.sin and > math.sqrt. However, same test in C# dominates (10ms.. as opposed to > upwards of 5 seconds in IP or CPy). Am I missing something here? > > Thanks, > > - Chris > > ----------------------------------- > > import time > from math import * > > def do_timing(f, reps): > start = time.time() > f(reps) > end = time.time() > print "%s (%d reps): %f" % (f.__name__, reps, end-start) > > > def py_fpfunc_test(reps): > j = 0.0 > for i in range(0, reps): > j += sin( j ) > j += sqrt( j ) > j +=2.72392032032; > print j > > def do_all_timing(): > do_timing(py_fpfunc_test, 5000000) > > do_all_timing() > print "" > > > ------------------------------ > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > End of users Digest, Vol 21, Issue 18 > ************************************* > > > > ________________________________ > How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates. > > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > From trimble at pobox.com Mon Apr 17 23:59:06 2006 From: trimble at pobox.com (Chris Trimble) Date: Mon, 17 Apr 2006 14:59:06 -0700 Subject: [IronPython] Sin and Sqrt performance (Chris Trimble) In-Reply-To: References: <20060417214257.37781.qmail@web51311.mail.yahoo.com> Message-ID: I shouldn't have said "no difference". Should have written... xrange or while does actually make around a 10% difference. Of course this is nowhere near the 500x performance increase that C# seems to offer, which is why I said "no difference". :) Thanks, - C On 4/17/06, Chris Trimble wrote: > Did you try making the change on your end and see a change? It makes > no difference on my end. > > BTW, I had tried 'while' before making the original post. No > difference there either. In fact, range() has better performance than > 'while' in CPython for this code! > > - Chris > > > > > On 4/17/06, Dave wrote: > > Use xrange instead of range and there should be a pretty good performance > > improvement;) As is, your for loop creates a list of five million elements. > > A simple while loop would also do the trick although it's not as clean to > > look at. > > > > Dave > > > > users-request at lists.ironpython.com wrote: > > Send users mailing list submissions to > > users at lists.ironpython.com > > > > To subscribe or unsubscribe via the World Wide Web, visit > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > or, via email, send a message with subject or body 'help' to > > users-request at lists.ironpython.com > > > > You can reach the person managing the list at > > users-owner at lists.ironpython.com > > > > When replying, please edit your Subject line so it is more specific > > than "Re: Contents of users digest..." > > > > > > Today's Topics: > > > > 1. Sin and Sqrt performance (Chris Trimble) > > > > > > ---------------------------------------------------------------------- > > > > Message: 1 > > Date: Mon, 17 Apr 2006 11:47:35 -0700 > > From: "Chris Trimble" > > Subject: [IronPython] Sin and Sqrt performance > > To: "Discussion of IronPython" > > Message-ID: > > > > Content-Type: text/plain; charset=ISO-8859-1 > > > > IP doesn't do much better than CPython when using math.sin and > > math.sqrt. However, same test in C# dominates (10ms.. as opposed to > > upwards of 5 seconds in IP or CPy). Am I missing something here? > > > > Thanks, > > > > - Chris > > > > ----------------------------------- > > > > import time > > from math import * > > > > def do_timing(f, reps): > > start = time.time() > > f(reps) > > end = time.time() > > print "%s (%d reps): %f" % (f.__name__, reps, end-start) > > > > > > def py_fpfunc_test(reps): > > j = 0.0 > > for i in range(0, reps): > > j += sin( j ) > > j += sqrt( j ) > > j +=2.72392032032; > > print j > > > > def do_all_timing(): > > do_timing(py_fpfunc_test, 5000000) > > > > do_all_timing() > > print "" > > > > > > ------------------------------ > > > > _______________________________________________ > > users mailing list > > users at lists.ironpython.com > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > > End of users Digest, Vol 21, Issue 18 > > ************************************* > > > > > > > > ________________________________ > > How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates. > > > > > > _______________________________________________ > > users mailing list > > users at lists.ironpython.com > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > > > From dinov at exchange.microsoft.com Tue Apr 18 00:52:25 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 17 Apr 2006 15:52:25 -0700 Subject: [IronPython] Sin and Sqrt performance (Chris Trimble) In-Reply-To: Message-ID: <4039D552ADAB094BB1EA670F3E96214E0279AF71@df-foxhound-msg.exchange.corp.microsoft.com> I believe most of what you're experiencing is the cost of being dynamic, although we certainly have a lot of room for improvement here... I looked at this under the profiler and there is some sillyness in IronPython that can yield a ~10% perf gain on this micro benchmark (for example in place add of floating point doubles checks for 3 other types before seeing if the other type is a double - most likely it's a double and we should check that first). There's also a problem in that you hit an extremely slow code path in IronPython (in place addition). This is currently slow so we can get the correct semantics (of trying one type, then trying another w/o throwing after the 1st type failed). This is something we can improve, but it's not a small work item - I've gone ahead and filed a bug on this. Changing the code to do j = j + xyz yields about a 25% perf improvement for me though. Also, it looks like the range() call takes ~10% of the time on IronPython (the actual creation of the range) so I'm a little surprised that doesn't yield improvements either. We also probably take an additional perf hit because when we're doing the optimized dispatch to call sin and sqrt we don't do an inline type-check for double first. Instead we go down a code path that involves a call (Converter.TryConvertToDouble) which we could avoid... Which brings me back to the cost of being dynamic. All of these small improvements (not that 35% is something to look down at) won't get us that close to C#'s performance. What would be better here for the long-term is adding type inference support to IronPython so we can do this all very fast, and fall back to the slow path if things change due to being dynamic. This is something that we've considered doing, but it's not a 1.0 feature. Even then I think we'd be looking good if we got within 2x of C#'s performance given all the extra goodies you get by switching to a dynamic langauge. That being said, if at the end of the day some critical piece of code is running slow you can always fall back to C# to write that small piece of code. You can then load from IronPython and call into it directly. All in all the interop experience here is pretty smooth so this shouldn't create many problems (other than the logistics of having 2 programming languages, of course). Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Chris Trimble Sent: Monday, April 17, 2006 2:59 PM To: Discussion of IronPython Subject: Re: [IronPython] Sin and Sqrt performance (Chris Trimble) I shouldn't have said "no difference". Should have written... xrange or while does actually make around a 10% difference. Of course this is nowhere near the 500x performance increase that C# seems to offer, which is why I said "no difference". :) Thanks, - C On 4/17/06, Chris Trimble wrote: > Did you try making the change on your end and see a change? It makes > no difference on my end. > > BTW, I had tried 'while' before making the original post. No > difference there either. In fact, range() has better performance than > 'while' in CPython for this code! > > - Chris > > > > > On 4/17/06, Dave wrote: > > Use xrange instead of range and there should be a pretty good performance > > improvement;) As is, your for loop creates a list of five million elements. > > A simple while loop would also do the trick although it's not as clean to > > look at. > > > > Dave > > > > users-request at lists.ironpython.com wrote: > > Send users mailing list submissions to > > users at lists.ironpython.com > > > > To subscribe or unsubscribe via the World Wide Web, visit > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > or, via email, send a message with subject or body 'help' to > > users-request at lists.ironpython.com > > > > You can reach the person managing the list at > > users-owner at lists.ironpython.com > > > > When replying, please edit your Subject line so it is more specific > > than "Re: Contents of users digest..." > > > > > > Today's Topics: > > > > 1. Sin and Sqrt performance (Chris Trimble) > > > > > > ---------------------------------------------------------------------- > > > > Message: 1 > > Date: Mon, 17 Apr 2006 11:47:35 -0700 > > From: "Chris Trimble" > > Subject: [IronPython] Sin and Sqrt performance > > To: "Discussion of IronPython" > > Message-ID: > > > > Content-Type: text/plain; charset=ISO-8859-1 > > > > IP doesn't do much better than CPython when using math.sin and > > math.sqrt. However, same test in C# dominates (10ms.. as opposed to > > upwards of 5 seconds in IP or CPy). Am I missing something here? > > > > Thanks, > > > > - Chris > > > > ----------------------------------- > > > > import time > > from math import * > > > > def do_timing(f, reps): > > start = time.time() > > f(reps) > > end = time.time() > > print "%s (%d reps): %f" % (f.__name__, reps, end-start) > > > > > > def py_fpfunc_test(reps): > > j = 0.0 > > for i in range(0, reps): > > j += sin( j ) > > j += sqrt( j ) > > j +=2.72392032032; > > print j > > > > def do_all_timing(): > > do_timing(py_fpfunc_test, 5000000) > > > > do_all_timing() > > print "" > > > > > > ------------------------------ > > > > _______________________________________________ > > users mailing list > > users at lists.ironpython.com > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > > End of users Digest, Vol 21, Issue 18 > > ************************************* > > > > > > > > ________________________________ > > How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates. > > > > > > _______________________________________________ > > users mailing list > > users at lists.ironpython.com > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > > > _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Tue Apr 18 01:17:35 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 17 Apr 2006 16:17:35 -0700 Subject: [IronPython] Are two PythonEngine instances connected? In-Reply-To: <000601c6624e$78725dd0$0f01a8c0@notebook> Message-ID: <4039D552ADAB094BB1EA670F3E96214E0279AFBE@df-foxhound-msg.exchange.corp.microsoft.com> Great feedback, thanks for the detailed explanation. It sounds like the level of isolation that you need is to simply support multiple sys instances, and each engine would then see its own system state. This is actually the original path we took with this, but we didn't quite get it working 100% L. What this would imply is that everything else is shared (e.g. id(str) would always be the same between multiple engines) but because all of the built-in types are read-only this should be a non-issue. This is one of our remaining open design issues for 1.0 so we'll make sure to let you know what way we end up landing with this. Unfortunately for now it seems like you'll be stuck using a single engine unless you wanted to start running your scripts in a separate app domain (which may or may not even be possible depending on what else you're doing). If you really wanted to get wacky you could try making Ops.systemState [ThreadStatic] but I would expect to get some nasty side effects from that. I'm in a 100% agreement about the confusion by allowing you to make multiple engines. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Kristof Wagemans Sent: Monday, April 17, 2006 11:41 AM To: 'Discussion of IronPython' Subject: Re: [IronPython] Are two PythonEngine instances connected? I'm thinking of using IronPython as a scripting language inside a future WPF application. (I'm just experimenting; there's nothing planned at the moment.) Here's an example of what I would like to do. I have a data object that's data bound to the user interface. When the user changes a property (or it's changed programmatically) I would like to run a custom script. This script gets a reference (SetVariable) to the changed object. It can now calculate and set a different property on the data object (or on some other object or send an e-mail or whatever). Setting the property can trigger a new script to run while the previous one isn't finished executing yet. The new script should run in a clean environment to exclude unwanted interactions: it could use the same variables or have conflicting functions defined. Is there a way to keep the script environments separated? With a single PythonEngine you also wouldn't have to pay the startup cost each time. This could give unacceptable delays while running the application anyway. I think that some form of sharing is unavoidable. It would still be nice to have separate instances though, maybe one PythonEngine per separate task that the user starts. I would also like to include inside the application an interactive console. I have a prototype working. It doesn't run in a blocking loop anymore: the application's UI keeps running normally. Multiple of these interactive sessions could be opened at the same time. I need the output of each engine to go to the correct console. This is how I stumbled across the problem. In my main window I used the console to create a new instance of the same window (which also contained an instance of my PythonConsole). But all the output of the first console suddenly showed up in the second console, which was a bit surprising. If you can't make the changes to have multiple PythonEngine's running at the same time it would be safest to make it impossible to create them. It wouldn't surprise me if other people run into the same problem if they integrate IronPython into their applications. ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland Sent: Monday 17 April 2006 16:58 To: Discussion of IronPython Subject: Re: [IronPython] Are two PythonEngine instances connected? Yes, right now we unfortunately have some shared state between them. We're not entirely certain where we'll land w/ this for V1 yet - whether we'll attempt to keep them separated entirely, or make it obvious (e.g. a static class) that there's only one engine available. If we end up w/ just one then our isolation story would be app domain isolation. If you've got feedback on which one is better for you (I'm guessing having them be independent) we'd love to hear it. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Kristof Wagemans Sent: Sunday, April 16, 2006 6:02 AM To: users at lists.ironpython.com Subject: [IronPython] Are two PythonEngine instances connected? I've created two PythonEngine instances and set the Stdout for each instance to its own custom stream class (PythonStream) to capture the output. This stream class takes a delegate to specify the function to receive the response. class Tester { public void Test() { PythonEngine pythonEngine1 = new PythonEngine(); pythonEngine1.SetStdout(new PythonStream(ResponsePythonEngine1)); Console.WriteLine("pythonEngine1.Execute(\"'p1'\") -> "); pythonEngine1.Execute("'p1'"); Console.WriteLine(""); PythonEngine pythonEngine2 = new PythonEngine(); pythonEngine2.SetStdout(new PythonStream(ResponsePythonEngine2)); Console.WriteLine("pythonEngine2.Execute(\"'p2'\") -> "); pythonEngine2.Execute("'p2'"); Console.WriteLine(""); Console.WriteLine("pythonEngine1.Execute(\"'p1'\") -> "); pythonEngine1.Execute("'p1'"); Console.WriteLine(""); Console.ReadLine(); } void ResponsePythonEngine1(string text) { if (!string.IsNullOrEmpty(text.Trim())) { Console.WriteLine(" ResponsePythonEngine1 -> " + text); } } void ResponsePythonEngine2(string text) { if (!string.IsNullOrEmpty(text.Trim())) { Console.WriteLine(" ResponsePythonEngine2 -> " + text); } } } After pythonEngine2 is created I receive the responses from commands executed on pythonEngine1 on the output of pythonEngine2. pythonEngine1.Execute("'p1'") -> ResponsePythonEngine1 -> 'p1' pythonEngine2.Execute("'p2'") -> ResponsePythonEngine2 -> 'p2' pythonEngine1.Execute("'p1'") -> ResponsePythonEngine2 -> 'p1' You can find my test application here: http://users.telenet.be/kristof.wagemans/PythonEngineConnected.zip -------------- next part -------------- An HTML attachment was scrubbed... URL: From trimble at pobox.com Tue Apr 18 01:33:46 2006 From: trimble at pobox.com (Chris Trimble) Date: Mon, 17 Apr 2006 16:33:46 -0700 Subject: [IronPython] Sin and Sqrt performance (Chris Trimble) In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E0279AF71@df-foxhound-msg.exchange.corp.microsoft.com> References: <4039D552ADAB094BB1EA670F3E96214E0279AF71@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: On 4/17/06, Dino Viehland wrote: > Changing the code to do j = j + xyz yields about a 25% perf > improvement for me though. Thanks for looking into this Dino. Oddly, I get the opposite result for this case! I ran the test 3x with j = j + and 3x with j +=. I got: j = j + .... 5.719s 5.656s 5.547s j += ..... 5.625s 5.578s 5.406s Is there an optimization flag I should be using? > Which brings me back to the cost of being dynamic. > All of these small improvements (not that 35% is something > to look down at) won't get us that close to C#'s performance. > What would be better here for the long-term is adding type > inference support to IronPython so we can do this all very fast, > and fall back to the slow path if things change due to being dynamic. Given what you said here I decided to give Boo's type inference a try and see what it came up with. At the end of the message is my (hacked up) code in Boo. Odd result again... the resulting timing comes out to be _faster_ than C# (~4ms compared to 10ms for C#). Could be Boo might be running on CLR 1.1 while C# is running on 2.0, haven't bothered to verify. Anyway, unless I'm doing something horribly wrong, it's a good datapoint. Thanks again for the explanation, it's been very helpful... and great work on IP! - Chris -------- def py_fpfunc_test(reps as int): j = 0.0 i = 0 while i < reps: j += System.Math.Sin( j ) j += System.Math.Sqrt( j ) j += 2.72392032032; i += 1 print j def do_all_timing(): start = System.DateTime.Now py_fpfunc_test(5000000) end = System.DateTime.Now print("{0} ({1} reps): {2}" % ("fpfunc", 5000000, (end.Ticks-start.Ticks) / 1000000.0)) do_all_timing() From ernsnat at iit.edu Tue Apr 18 01:40:30 2006 From: ernsnat at iit.edu (Nathan R. Ernst) Date: Mon, 17 Apr 2006 18:40:30 -0500 Subject: [IronPython] Sin and Sqrt performance (Chris Trimble) In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E0279AF71@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <20060417234029.38FC91BB65@che.dreamhost.com> I looked at this under the profiler and there is some sillyness in IronPython that can yield a ~10% perf gain on this micro benchmark (for example in place add of floating point doubles checks for 3 other types before seeing if the other type is a double - most likely it's a double and we should check that first). Couple of toughts on this: Wouldn't it be the common case that the types on the lhs and rhs of an operator are the same? Also, in the case where the rhs is a literal, don't you *know* what the type is implicitly (I'm afraid I don't know if this is being taken into consideration currently)? It also comes to mind that successive iterations through a loop are likely to yield the same types for function alls. Might it be possible to cache the type information, and recalculation only if a problem is encountered (such as an int became a long integer, or an iterator that was returning ints started returning strings)? On a tangential topic, Dino, what are you using to profile the code? All I'm aware of is the CLR profiler, but doesn't this only profile allocations? -Nathan Ernst From dinov at exchange.microsoft.com Tue Apr 18 01:45:03 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 17 Apr 2006 16:45:03 -0700 Subject: [IronPython] Sin and Sqrt performance (Chris Trimble) In-Reply-To: Message-ID: <4039D552ADAB094BB1EA670F3E96214E0279AFF7@df-foxhound-msg.exchange.corp.microsoft.com> I was running on a pre-beta 6 build, so there could be some slight differences. I also had made a change to switch from range to xrange. It could be that switching to xrange lets the faster + path start to matter, otherwise working set issues could dominate. Tough to say... I wonder if Boo could have optimized away the entire loop (in theory they could notice the calls into Math and optimize those)... Note the 4ms is basically equal to zero because the precision of DateTime.Now isn't very good. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Chris Trimble Sent: Monday, April 17, 2006 4:34 PM To: Discussion of IronPython Subject: Re: [IronPython] Sin and Sqrt performance (Chris Trimble) On 4/17/06, Dino Viehland wrote: > Changing the code to do j = j + xyz yields about a 25% perf > improvement for me though. Thanks for looking into this Dino. Oddly, I get the opposite result for this case! I ran the test 3x with j = j + and 3x with j +=. I got: j = j + .... 5.719s 5.656s 5.547s j += ..... 5.625s 5.578s 5.406s Is there an optimization flag I should be using? > Which brings me back to the cost of being dynamic. > All of these small improvements (not that 35% is something > to look down at) won't get us that close to C#'s performance. > What would be better here for the long-term is adding type > inference support to IronPython so we can do this all very fast, > and fall back to the slow path if things change due to being dynamic. Given what you said here I decided to give Boo's type inference a try and see what it came up with. At the end of the message is my (hacked up) code in Boo. Odd result again... the resulting timing comes out to be _faster_ than C# (~4ms compared to 10ms for C#). Could be Boo might be running on CLR 1.1 while C# is running on 2.0, haven't bothered to verify. Anyway, unless I'm doing something horribly wrong, it's a good datapoint. Thanks again for the explanation, it's been very helpful... and great work on IP! - Chris -------- def py_fpfunc_test(reps as int): j = 0.0 i = 0 while i < reps: j += System.Math.Sin( j ) j += System.Math.Sqrt( j ) j += 2.72392032032; i += 1 print j def do_all_timing(): start = System.DateTime.Now py_fpfunc_test(5000000) end = System.DateTime.Now print("{0} ({1} reps): {2}" % ("fpfunc", 5000000, (end.Ticks-start.Ticks) / 1000000.0)) do_all_timing() _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Tue Apr 18 01:54:09 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 17 Apr 2006 16:54:09 -0700 Subject: [IronPython] Sin and Sqrt performance (Chris Trimble) In-Reply-To: <20060417234029.38FC91BB65@che.dreamhost.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E0279B014@df-foxhound-msg.exchange.corp.microsoft.com> Yes, I would think the likelihood would be the two types being the same :) But currently we check for int, BigInteger, and complex before we check for double for some reason... it's just silly. We don't currently do any magic w/ literals to treat them specially... They just become objects and then later the runtime does its normal logic for dealing w/ objects. But this would be the place to start for type inference. The problem w/ the loop optimizations you describe is the code is already compiled by the time we come to the 1st iteration. If we had some hints (e.g. there was a literal) we could have code that generates the guess and falls back to the slow path if that doesn't work. But if we had a literal we could hint off (or a hint that flowed from a literal) then we'd be in business. Given that we're doing nothing today there's lots of room for improvement here :). I'm using Visual Studio 2005 Team Suite to do the profiling using it's sampling profiler. Its pretty simple to use and gets the job done. CLR Profiler does include a call graph I believe but I don't think it gives you the timing information that VS does. I end up using CLR Profiler when I need to drill down into allocations more closely (and WinDbg when I need to debug the CPython weakref tests :) ). Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nathan R. Ernst Sent: Monday, April 17, 2006 4:41 PM To: 'Discussion of IronPython' Subject: Re: [IronPython] Sin and Sqrt performance (Chris Trimble) I looked at this under the profiler and there is some sillyness in IronPython that can yield a ~10% perf gain on this micro benchmark (for example in place add of floating point doubles checks for 3 other types before seeing if the other type is a double - most likely it's a double and we should check that first). Couple of toughts on this: Wouldn't it be the common case that the types on the lhs and rhs of an operator are the same? Also, in the case where the rhs is a literal, don't you *know* what the type is implicitly (I'm afraid I don't know if this is being taken into consideration currently)? It also comes to mind that successive iterations through a loop are likely to yield the same types for function alls. Might it be possible to cache the type information, and recalculation only if a problem is encountered (such as an int became a long integer, or an iterator that was returning ints started returning strings)? On a tangential topic, Dino, what are you using to profile the code? All I'm aware of is the CLR profiler, but doesn't this only profile allocations? -Nathan Ernst _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From trimble at pobox.com Tue Apr 18 01:57:20 2006 From: trimble at pobox.com (Chris Trimble) Date: Mon, 17 Apr 2006 16:57:20 -0700 Subject: [IronPython] Sin and Sqrt performance (Chris Trimble) In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E0279AFF7@df-foxhound-msg.exchange.corp.microsoft.com> References: <4039D552ADAB094BB1EA670F3E96214E0279AFF7@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: On 4/17/06, Dino Viehland wrote: > I wonder if Boo could have optimized away the entire loop > (in theory they could notice the calls into Math and optimize those)... > Note the 4ms is basically equal to zero because the precision > of DateTime.Now isn't very good. Oh blah! I knew something was up here... I totally messed up my ticks conversion to ms. A tick is 100ns, so it should be divide by 10k, not 1m. New stat: IP = ~5.5 seconds. Boo = ~450ms. C# = ~1.15s. I added a modulo print of i every 1m in the Boo loop to make sure it was doing the work. And the end result of j is printed, so hopefully it's doing something other than optimizing the loop out completely. - Chris From dinov at exchange.microsoft.com Tue Apr 18 03:22:50 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 17 Apr 2006 18:22:50 -0700 Subject: [IronPython] Sin and Sqrt performance (Chris Trimble) In-Reply-To: References: <4039D552ADAB094BB1EA670F3E96214E0279AFF7@df-foxhound-msg.exchange.corp.microsoft.com>, Message-ID: <4039D552ADAB094BB1EA670F3E96214E235C63@df-foxhound-msg.exchange.corp.microsoft.com> Strange... Could 0.0 be a float instead of a double? I'm not sure if that'd be faster or slower... Maybe it's time to diff the generated IL. ________________________________________ From: users-bounces at lists.ironpython.com On Behalf Of Chris Trimble Sent: Monday, April 17, 2006 4:57 PM To: Discussion of IronPython Subject: Re: [IronPython] Sin and Sqrt performance (Chris Trimble) On 4/17/06, Dino Viehland wrote: > I wonder if Boo could have optimized away the entire loop > (in theory they could notice the calls into Math and optimize those)... > Note the 4ms is basically equal to zero because the precision > of DateTime.Now isn't very good. Oh blah! I knew something was up here... I totally messed up my ticks conversion to ms. A tick is 100ns, so it should be divide by 10k, not 1m. New stat: IP = ~5.5 seconds. Boo = ~450ms. C# = ~1.15s. I added a modulo print of i every 1m in the Boo loop to make sure it was doing the work. And the end result of j is printed, so hopefully it's doing something other than optimizing the loop out completely. - Chris _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From kristof.wagemans at gmail.com Tue Apr 18 20:38:16 2006 From: kristof.wagemans at gmail.com (Kristof Wagemans) Date: Tue, 18 Apr 2006 20:38:16 +0200 Subject: [IronPython] Are two PythonEngine instances connected? In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E0279AFBE@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <000001c66317$431eafc0$0f01a8c0@notebook> I don't think that I would really require multiple engine instances if I could use separated sessions (system states). I could keep the states around and swap them in and out as required. One possible problem: I create a new session and run a script in it. This script triggers the execution of another script. I would then need to unplug the current session, create a new session and run the script inside it. After the second script finishes I need to put the original session back and let it finish executing. I can imagine that it would give problems to swap sessions while one was executing (although it was temporarily suspended). Using AppDomains or multiple Threads doesn't seem like a workable solution. It would get very complex to make the data the PythonEngine needs to operate on available in the other AppDomain. As for using threads: multithreading and user interfaces don't work well together. (I would have hoped that WPF fixed this problem, but alas.) I don't really need an immediate solution for this. I'm just experimenting now. I think that the scenario that I've outlined is an important use for IronPython: to integrate in a .NET application and extend it with programmable and flexible extra functionality. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Tue Apr 18 20:53:37 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Tue, 18 Apr 2006 11:53:37 -0700 Subject: [IronPython] Are two PythonEngine instances connected? In-Reply-To: <000001c66317$431eafc0$0f01a8c0@notebook> Message-ID: <4039D552ADAB094BB1EA670F3E96214E02857559@df-foxhound-msg.exchange.corp.microsoft.com> We've been discussing this internally and we believe we actually have the right solution, but it's not trivial - so it looks like it'll happen in beta 7 (there's a small chance we may decide not to do it entirely still, but hopefully that won't happen). The solution involves saving the system state in our caller context and flowing it to places that would load additional modules. But theres a lot of details that we'll need to get right to make it all work, and it may uncover a few bugs in our caller context implementation as well. So hopefully you can get along for the next month or so and we'll be able to get the work done for 1.0. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Kristof Wagemans Sent: Tuesday, April 18, 2006 11:38 AM To: 'Discussion of IronPython' Subject: Re: [IronPython] Are two PythonEngine instances connected? I don't think that I would really require multiple engine instances if I could use separated sessions (system states). I could keep the states around and swap them in and out as required. One possible problem: I create a new session and run a script in it. This script triggers the execution of another script. I would then need to unplug the current session, create a new session and run the script inside it. After the second script finishes I need to put the original session back and let it finish executing. I can imagine that it would give problems to swap sessions while one was executing (although it was temporarily suspended). Using AppDomains or multiple Threads doesn't seem like a workable solution. It would get very complex to make the data the PythonEngine needs to operate on available in the other AppDomain. As for using threads: multithreading and user interfaces don't work well together. (I would have hoped that WPF fixed this problem, but alas...) I don't really need an immediate solution for this. I'm just experimenting now. I think that the scenario that I've outlined is an important use for IronPython: to integrate in a .NET application and extend it with programmable and flexible extra functionality. -------------- next part -------------- An HTML attachment was scrubbed... URL: From joesox at gmail.com Wed Apr 19 08:33:42 2006 From: joesox at gmail.com (JoeSox) Date: Tue, 18 Apr 2006 23:33:42 -0700 Subject: [IronPython] Speed test In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E0279A964@df-foxhound-msg.exchange.corp.microsoft.com> References: <785694cd0604160806k31d65c86s8e6cf303852288a0@mail.gmail.com> <4039D552ADAB094BB1EA670F3E96214E0279A964@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <785694cd0604182333q1348f4b9o9ff3e0e419496651@mail.gmail.com> Thanks Dino for double-checking me there. I'm not sure if you, or anyone else, is interested as to why I asked but I'll surely entertain you and some others for a couple of seconds. :) I also get the same results from the unpp test, my last test results were... 1st run: 0.1718750 2 to about 6th run: 0.0 est. 7th run: 0.0156250 Don't get me wrong, I am not complaining. However, I am trying to rewrite ConceptNet 2.1 to be used with .Net (just as a learning experience mostly for myself, some odd reason I find it fun, wheither I ever get enough time to complete it, is another matter) and ConceptNet loads, by default, three huge text files of those predicate sequence lines which is then loaded into a very large semantic network. At first I tried loading these predicate lines into a StringCollection, which works great when using System.IO.File.ReadAllLines() but things slow down significantly when I try to enumerate the StringCollection into a PythonEngine. So, it looks like staying away from .Net objects, as much as possible, and actually rewriting the Python code to blend with IronPython is currently looks like the way I need to go. So I was able to speed test the loading of the three predicate files and ConceptNet's creation of some huge dictionary objects which is used for its semantic mapping. Both apps basically load: (1.4mb) predicates_concise_nonkline.txt: loads 27000 predicates (10.2mb) predicates_concise_kline.txt: loads 174000 predicates (19.5mb) predicates_nonconcise_nonkline.txt: loads 348000 predicates Python clocks in at 52.907753 seconds* My C# Method clocks in at 4:40.4845 I created a new XmlTextReader to read in the settings file which holds the 3 predicate file paths. I then set time1 then call: ipEngine1.SetVariable("pred_file", predfile); ipEngine1.Execute(@"db.load_predicates_file(pred_file)"); After the XmlTextReader is closed I set time2: time2 = DateTime.Now; MessageBox.Show(Convert.ToString(time2.Subtract(time1))); * I added the time lines around the method: time1=time.clock() self.load_predicates() time2=time.clock() to class ConceptNetDB So I will keep on tweaking things until I get a better load time for the predicate files. I am thinking out loud here but I may need to pass the loading to the Console and then grab the semantic mapping dictionaries that way. Just in case anyone is really bored I uploaded my import file that is currently my version of ConceptNet's ConceptNetDB.py. http://www.joeswammi.com/projects/CNUDB.py in the C# speed test above I call //IronPython... ipEngine1.Execute("import sys"); ipEngine1.Execute("sys.path.append('E:\')"); ipEngine1.Execute("import CNUDB"); ipEngine1.Execute("db=CNUDB.ConceptNetDB()"); string predfile = ""; DateTime time1 = new DateTime(); DateTime time2 = new DateTime(); before reading the XML settings file. -- Joseph On 4/17/06, Dino Viehland wrote: > IronPython is slower to get things going the first time (because we end up compiling to IL and then JITing the code); it's after that when we really start to shine. > > The first time you run this we will take longer to execute it, but if you do it a second time we'll report zero. When I run it the first time I get ~.20 seconds, the second time I get 0 seconds - which is just below the precision of the clock. > > > Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of JoeSox > Sent: Sunday, April 16, 2006 8:07 AM > To: Discussion of IronPython > Subject: [IronPython] Speed test > > Am I doing this speed test correctly using the script and process below? > > I have unpp.py on a usb jumpdrive E > ------- > #unpp.py > import time > > def unpp(pp): > time1=time.clock() > toks = pp.strip(' ()\n').split() > pred = toks[0] > args = ' '.join(toks[1:])[1:-1].split('" "') > f,i = map(lambda x:int(x.split('=')[1]),args.pop().split(';')[:2]) > time2=time.clock() > print pred,args[0],args[1],f,i > print time1 > print time2 > print "-- unpp took",str(round(time2-time1,6)),'seconds. --\n' > ---------- > > ===== I run a test in IDLE > Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32 > IDLE 1.1.2 ==== No Subprocess ==== > >>> import sys > >>> sys.path.append('E/') > >>> import unpp > >>> p=unpp > >>> p.unpp('(CapableOf \"red bicycle\" \"pump\" \"f=2;i=1;\")') > CapableOf red bicycle pump 2 1 > 50.3331431788 > 50.3331713947 > -- unpp took 2.8e-005 seconds. -- > ===== END of IDLE test 2.8e-005 = 0.000028 > > > ====== I run same test in IronPythonConsole > IronPython 1.0.2280 (Beta) on .NET 2.0.50727.42 > Copyright (c) Microsoft Corporation. All rights reserved. > >>> import sys > >>> sys.path.append('E:/') > >>> import unpp > >>> p=unpp > >>> p.unpp('(CapableOf \"red bicycle\" \"pump\" \"f=2;i=1;\")') > CapableOf red bicycle pump 2 1 > 63280770878.0 > 63280770878.0 > -- unpp took 0.046867 seconds. -- > ===== END of IronPythonConsole test > > If I am doing this correctly, there seems to be a big process time > difference, does this seem to be correct, or I am missing something or > doing the time() incorrectly? > Thanks! > -- > Joseph From joesox at gmail.com Wed Apr 19 08:37:44 2006 From: joesox at gmail.com (JoeSox) Date: Tue, 18 Apr 2006 23:37:44 -0700 Subject: [IronPython] Speed test In-Reply-To: <785694cd0604182333q1348f4b9o9ff3e0e419496651@mail.gmail.com> References: <785694cd0604160806k31d65c86s8e6cf303852288a0@mail.gmail.com> <4039D552ADAB094BB1EA670F3E96214E0279A964@df-foxhound-msg.exchange.corp.microsoft.com> <785694cd0604182333q1348f4b9o9ff3e0e419496651@mail.gmail.com> Message-ID: <785694cd0604182337k62558502w27877ddfbbdb822c@mail.gmail.com> On 4/18/06, JoeSox wrote: > My C# Method clocks in at 4:40.4845 I suppose I need to clarify that is meant to read 4 minutes 40 seconds -- Joseph From SrinivasaRao_k at apollolife.com Wed Apr 19 08:50:08 2006 From: SrinivasaRao_k at apollolife.com (Srinivasa Rao) Date: Wed, 19 Apr 2006 12:20:08 +0530 Subject: [IronPython] Speed test In-Reply-To: <785694cd0604182337k62558502w27877ddfbbdb822c@mail.gmail.com> Message-ID: I don't know Thanks & Regards Srinivasa Rao. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com]On Behalf Of JoeSox Sent: Wednesday, April 19, 2006 12:08 PM To: Discussion of IronPython Subject: Re: [IronPython] Speed test On 4/18/06, JoeSox wrote: > My C# Method clocks in at 4:40.4845 I suppose I need to clarify that is meant to read 4 minutes 40 seconds -- Joseph _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ? This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error, please notify the ISMS team of AHSL through ISMS at apollolife.com? From joesox at gmail.com Wed Apr 19 08:55:54 2006 From: joesox at gmail.com (JoeSox) Date: Tue, 18 Apr 2006 23:55:54 -0700 Subject: [IronPython] Speed test In-Reply-To: References: <785694cd0604182337k62558502w27877ddfbbdb822c@mail.gmail.com> Message-ID: <785694cd0604182355m70097b8bp9393348f1dcb193c@mail.gmail.com> On 4/18/06, Srinivasa Rao wrote: > I don't know > > Thanks & Regards > Srinivasa Rao. It actually read "00:04:40.4845" Sorry, I possibly typed it in a confusing way. -- Joseph From sanxiyn at gmail.com Wed Apr 19 10:07:23 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Wed, 19 Apr 2006 17:07:23 +0900 Subject: [IronPython] socket for IronPython update In-Reply-To: <5b0248170604140818w2525f5f7mba96b8c5c631a8bd@mail.gmail.com> References: <5b0248170604140818w2525f5f7mba96b8c5c631a8bd@mail.gmail.com> Message-ID: <5b0248170604190107q43068bcfs4a36e4df8afbd6eb@mail.gmail.com> socket.py for IronPython now has an SSL support. http://sparcs.kaist.ac.kr/~tinuviel/fepy/lib/ ssl.py can use either SslStream from System.Net.Security or SslClientStream from Mono.Security.Protocol.Tls. This is because System.Net.Security classes are new in .NET 2.0 and not implemented (stubbed) in Mono, but Mono had its own implementation of SSL before .NET 2.0 came. Python side of interface is exactly same as socket.ssl of CPython. I added a new example using poplib's POP3_SSL class to connect to GMail POP3 SSL server, that you can run with both CPython and IronPython. http://sparcs.kaist.ac.kr/~tinuviel/fepy/example/pop3s_test.py Enjoy! Seo Sanghyeon From porkone at wp.pl Wed Apr 19 13:32:01 2006 From: porkone at wp.pl (Albert Einstein) Date: Wed, 19 Apr 2006 13:32:01 +0200 Subject: [IronPython] Regexp issue, or not :) Message-ID: <44461fb1d33a4@wp.pl> I checked sample from Python Regexp tutorial and I found something strange. CPython and IronPython: m = re.compile("[a-z]+") p = m.match("sometext") p.group() *CPython returns: 'sometext' *IronPython returns: Traceback (most recent call last): File , line 0, in input##44 File , line 0, in group##15 IndexError: Index was outside the bounds of the array. Is it bug in IronPython? I'm using version IP 1.0 beta 5. ---------------------------------------------------- ODA DO RADO?CI w kinach od 19 kwietnia! http://klik.wp.pl/?adr=http%3A%2F%2Fadv.reklama.wp.pl%2Fas%2Foda.html&sid=726 From sanxiyn at gmail.com Wed Apr 19 15:48:40 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Wed, 19 Apr 2006 22:48:40 +0900 Subject: [IronPython] Regexp issue, or not :) In-Reply-To: <44461fb1d33a4@wp.pl> References: <44461fb1d33a4@wp.pl> Message-ID: <5b0248170604190648h2623e84dva469a95c2d8704d0@mail.gmail.com> 2006/4/19, Albert Einstein : > m = re.compile("[a-z]+") > p = m.match("sometext") > p.group() > > Traceback (most recent call last): > File , line 0, in input##44 > File , line 0, in group##15 > IndexError: Index was outside the bounds of the array. > > Is it bug in IronPython? Yes it is. The documentation says: http://docs.python.org/lib/match-objects.html group([group1, ...]) Without arguments, group1 defaults to zero (the whole match is returned). Here's a simple fix: --- IronPython/Modules/re.cs.orig 2006-04-19 22:28:31.000000000 +0900 +++ IronPython/Modules/re.cs 2006-04-19 22:28:42.000000000 +0900 @@ -518,6 +518,11 @@ } [PythonName("group")] + public object group() { + return m.Groups[0].Value; + } + + [PythonName("group")] public object group(object index) { return m.Groups[GetGroupIndex(index)].Value; } Seo Sanghyeon From dinov at exchange.microsoft.com Wed Apr 19 16:50:39 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 19 Apr 2006 07:50:39 -0700 Subject: [IronPython] Regexp issue, or not :) In-Reply-To: <5b0248170604190648h2623e84dva469a95c2d8704d0@mail.gmail.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E02857BDA@df-foxhound-msg.exchange.corp.microsoft.com> Yep, and this will be in beta 6. It was also reported to the www.gotdotnet.com bug database a while ago. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sanghyeon Seo Sent: Wednesday, April 19, 2006 6:49 AM To: Discussion of IronPython Subject: Re: [IronPython] Regexp issue, or not :) 2006/4/19, Albert Einstein : > m = re.compile("[a-z]+") > p = m.match("sometext") > p.group() > > Traceback (most recent call last): > File , line 0, in input##44 > File , line 0, in group##15 > IndexError: Index was outside the bounds of the array. > > Is it bug in IronPython? Yes it is. The documentation says: http://docs.python.org/lib/match-objects.html group([group1, ...]) Without arguments, group1 defaults to zero (the whole match is returned). Here's a simple fix: --- IronPython/Modules/re.cs.orig 2006-04-19 22:28:31.000000000 +0900 +++ IronPython/Modules/re.cs 2006-04-19 22:28:42.000000000 +0900 @@ -518,6 +518,11 @@ } [PythonName("group")] + public object group() { + return m.Groups[0].Value; + } + + [PythonName("group")] public object group(object index) { return m.Groups[GetGroupIndex(index)].Value; } Seo Sanghyeon _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Wed Apr 19 17:00:34 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 19 Apr 2006 08:00:34 -0700 Subject: [IronPython] Speed test In-Reply-To: <785694cd0604182333q1348f4b9o9ff3e0e419496651@mail.gmail.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E02857BE0@df-foxhound-msg.exchange.corp.microsoft.com> Interop w/ C# shouldn't really cost you that much - it should actually be able to give you speed gains as you fall back into the static world... Do you know if most of the time is being spent in the XmlTextReader or in IronPython after that? And I'm having trouble parsing "but things slow down significantly when I try to enumerate the StringCollection into a PythonEngine". Is this just doing a set variable, or are you looping over the collection and doing a set variable one at a time? Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of JoeSox Sent: Tuesday, April 18, 2006 11:34 PM To: Discussion of IronPython Subject: Re: [IronPython] Speed test Thanks Dino for double-checking me there. I'm not sure if you, or anyone else, is interested as to why I asked but I'll surely entertain you and some others for a couple of seconds. :) I also get the same results from the unpp test, my last test results were... 1st run: 0.1718750 2 to about 6th run: 0.0 est. 7th run: 0.0156250 Don't get me wrong, I am not complaining. However, I am trying to rewrite ConceptNet 2.1 to be used with .Net (just as a learning experience mostly for myself, some odd reason I find it fun, wheither I ever get enough time to complete it, is another matter) and ConceptNet loads, by default, three huge text files of those predicate sequence lines which is then loaded into a very large semantic network. At first I tried loading these predicate lines into a StringCollection, which works great when using System.IO.File.ReadAllLines() but things slow down significantly when I try to enumerate the StringCollection into a PythonEngine. So, it looks like staying away from .Net objects, as much as possible, and actually rewriting the Python code to blend with IronPython is currently looks like the way I need to go. So I was able to speed test the loading of the three predicate files and ConceptNet's creation of some huge dictionary objects which is used for its semantic mapping. Both apps basically load: (1.4mb) predicates_concise_nonkline.txt: loads 27000 predicates (10.2mb) predicates_concise_kline.txt: loads 174000 predicates (19.5mb) predicates_nonconcise_nonkline.txt: loads 348000 predicates Python clocks in at 52.907753 seconds* My C# Method clocks in at 4:40.4845 I created a new XmlTextReader to read in the settings file which holds the 3 predicate file paths. I then set time1 then call: ipEngine1.SetVariable("pred_file", predfile); ipEngine1.Execute(@"db.load_predicates_file(pred_file)"); After the XmlTextReader is closed I set time2: time2 = DateTime.Now; MessageBox.Show(Convert.ToString(time2.Subtract(time1))); * I added the time lines around the method: time1=time.clock() self.load_predicates() time2=time.clock() to class ConceptNetDB So I will keep on tweaking things until I get a better load time for the predicate files. I am thinking out loud here but I may need to pass the loading to the Console and then grab the semantic mapping dictionaries that way. Just in case anyone is really bored I uploaded my import file that is currently my version of ConceptNet's ConceptNetDB.py. http://www.joeswammi.com/projects/CNUDB.py in the C# speed test above I call //IronPython... ipEngine1.Execute("import sys"); ipEngine1.Execute("sys.path.append('E:\')"); ipEngine1.Execute("import CNUDB"); ipEngine1.Execute("db=CNUDB.ConceptNetDB()"); string predfile = ""; DateTime time1 = new DateTime(); DateTime time2 = new DateTime(); before reading the XML settings file. -- Joseph On 4/17/06, Dino Viehland wrote: > IronPython is slower to get things going the first time (because we end up compiling to IL and then JITing the code); it's after that when we really start to shine. > > The first time you run this we will take longer to execute it, but if you do it a second time we'll report zero. When I run it the first time I get ~.20 seconds, the second time I get 0 seconds - which is just below the precision of the clock. > > > Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of JoeSox > Sent: Sunday, April 16, 2006 8:07 AM > To: Discussion of IronPython > Subject: [IronPython] Speed test > > Am I doing this speed test correctly using the script and process below? > > I have unpp.py on a usb jumpdrive E > ------- > #unpp.py > import time > > def unpp(pp): > time1=time.clock() > toks = pp.strip(' ()\n').split() > pred = toks[0] > args = ' '.join(toks[1:])[1:-1].split('" "') > f,i = map(lambda x:int(x.split('=')[1]),args.pop().split(';')[:2]) > time2=time.clock() > print pred,args[0],args[1],f,i > print time1 > print time2 > print "-- unpp took",str(round(time2-time1,6)),'seconds. --\n' > ---------- > > ===== I run a test in IDLE > Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32 > IDLE 1.1.2 ==== No Subprocess ==== > >>> import sys > >>> sys.path.append('E/') > >>> import unpp > >>> p=unpp > >>> p.unpp('(CapableOf \"red bicycle\" \"pump\" \"f=2;i=1;\")') > CapableOf red bicycle pump 2 1 > 50.3331431788 > 50.3331713947 > -- unpp took 2.8e-005 seconds. -- > ===== END of IDLE test 2.8e-005 = 0.000028 > > > ====== I run same test in IronPythonConsole > IronPython 1.0.2280 (Beta) on .NET 2.0.50727.42 > Copyright (c) Microsoft Corporation. All rights reserved. > >>> import sys > >>> sys.path.append('E:/') > >>> import unpp > >>> p=unpp > >>> p.unpp('(CapableOf \"red bicycle\" \"pump\" \"f=2;i=1;\")') > CapableOf red bicycle pump 2 1 > 63280770878.0 > 63280770878.0 > -- unpp took 0.046867 seconds. -- > ===== END of IronPythonConsole test > > If I am doing this correctly, there seems to be a big process time > difference, does this seem to be correct, or I am missing something or > doing the time() incorrectly? > Thanks! > -- > Joseph _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From joesox at gmail.com Wed Apr 19 19:40:56 2006 From: joesox at gmail.com (JoeSox) Date: Wed, 19 Apr 2006 10:40:56 -0700 Subject: [IronPython] Speed test In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E02857BE0@df-foxhound-msg.exchange.corp.microsoft.com> References: <785694cd0604182333q1348f4b9o9ff3e0e419496651@mail.gmail.com> <4039D552ADAB094BB1EA670F3E96214E02857BE0@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <785694cd0604191040j65bd897tbd4c9c383a070fe0@mail.gmail.com> On 4/19/06, Dino Viehland wrote: > Interop w/ C# shouldn't really cost you that much - it should actually be able to give you speed gains as you fall back into the static world... > > Do you know if most of the time is being spent in the XmlTextReader or in IronPython after that? It just passes an else and and catch. I posted the rough draft of the test method here if you wish to see in more detail http://joeswammi.com/projects/InitializeDB.txt That test method above is a quickly modified version of an another method that actually passes out a StringCollection. Sorry, I haven't modified the code to be more reflective of what it is actually doing. But I believe I have captured the times correctly. And it seems to successfully create the semantic network of the predicate files within the PythonEngine. >And I'm having trouble parsing "but things slow down significantly when I try to enumerate the StringCollection into a PythonEngine". Is this just doing a set variable, or are you looping over the collection and doing a set variable one at a time? > Yes, here is a test method I used using unpp() http://joeswammi.com/projects/load_predicate_files.txt Ideally, this C# load_predicate_files() method would actually create the semantic dictionaries instead of passing the StringCollection nodes to just unpp(). I did try a more static approach... http://joeswammi.com/projects/load_predicate_files2.txt But I didn't like the results, could be my own fault though. It was very slow esp. when it reached around 3000 predicate lines from the StringCollection. -- Joseph From dinov at exchange.microsoft.com Wed Apr 19 23:01:34 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 19 Apr 2006 14:01:34 -0700 Subject: [IronPython] Speed test In-Reply-To: <785694cd0604191040j65bd897tbd4c9c383a070fe0@mail.gmail.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E028580AB@df-foxhound-msg.exchange.corp.microsoft.com> If in initializeDB you comment out: ipEngine1.SetVariable("pred_file", predfile); ipEngine1.Execute(@"db.load_predicates_file(pred_file)"); does it get much faster? If it doesn't then the problem is squarely an IronPython problem and we'll need to investigate further. The more static one has some issues... The GetObjectArray() call will be really expensive if your edges grow to be very big (it'll copy the array). Maybe that's what you need to do here though (and it looks like edge just grows unbounded as it never gets cleared). You also might be able to get rid of the Ops.GetEnumerator call for the Tuple, not that that should be very expensive though. NodesCollection is a StringCollection? Also, are you taking your performance measurements at the console, or in an imported py file? In general our performance is much better in imported files than it is at the console. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of JoeSox Sent: Wednesday, April 19, 2006 10:41 AM To: Discussion of IronPython Subject: Re: [IronPython] Speed test On 4/19/06, Dino Viehland wrote: > Interop w/ C# shouldn't really cost you that much - it should actually be able to give you speed gains as you fall back into the static world... > > Do you know if most of the time is being spent in the XmlTextReader or in IronPython after that? It just passes an else and and catch. I posted the rough draft of the test method here if you wish to see in more detail http://joeswammi.com/projects/InitializeDB.txt That test method above is a quickly modified version of an another method that actually passes out a StringCollection. Sorry, I haven't modified the code to be more reflective of what it is actually doing. But I believe I have captured the times correctly. And it seems to successfully create the semantic network of the predicate files within the PythonEngine. >And I'm having trouble parsing "but things slow down significantly when I try to enumerate the StringCollection into a PythonEngine". Is this just doing a set variable, or are you looping over the collection and doing a set variable one at a time? > Yes, here is a test method I used using unpp() http://joeswammi.com/projects/load_predicate_files.txt Ideally, this C# load_predicate_files() method would actually create the semantic dictionaries instead of passing the StringCollection nodes to just unpp(). I did try a more static approach... http://joeswammi.com/projects/load_predicate_files2.txt But I didn't like the results, could be my own fault though. It was very slow esp. when it reached around 3000 predicate lines from the StringCollection. -- Joseph _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From joesox at gmail.com Thu Apr 20 00:26:48 2006 From: joesox at gmail.com (JoeSox) Date: Wed, 19 Apr 2006 15:26:48 -0700 Subject: [IronPython] Speed test In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E028580AB@df-foxhound-msg.exchange.corp.microsoft.com> References: <785694cd0604191040j65bd897tbd4c9c383a070fe0@mail.gmail.com> <4039D552ADAB094BB1EA670F3E96214E028580AB@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <785694cd0604191526u76be05aclc796996a4cc15229@mail.gmail.com> On 4/19/06, Dino Viehland wrote: > If in initializeDB you comment out: > > > ipEngine1.SetVariable("pred_file", predfile); ipEngine1.Execute(@"db.load_predicates_file(pred_file)"); > > does it get much faster? Yes, I received a time of 00:00:00.0156250 > If it doesn't then the problem is squarely an IronPython problem and we'll need to investigate further. > > The more static one has some issues... The GetObjectArray() call will be really expensive if your edges grow to be very big (it'll copy the array). Maybe that's what you need to do here though (and it looks like edge just grows unbounded as it never gets cleared). > Yes, in Python there are a couple of variable objects like "fw_edges" that grow into "" etc (but to me they resemble more like IronPython List object). > You also might be able to get rid of the Ops.GetEnumerator call for the Tuple, not that that should be very expensive though. > > NodesCollection is a StringCollection? Yes. > Also, are you taking your performance measurements at the console, or in an imported py file? Recently, I have been using an imported py file. I am about to start testing using the console. I have been using a custom Progressbar Form to notify the user of what was happening but I might try using a console for the same concept to see if it is any faster. > In general our performance is much better in imported files than it is at the console. > This is good to know but not always ideal. I am trying to write a Class Library to so any app can use it. -- Joseph From dinov at exchange.microsoft.com Thu Apr 20 00:54:43 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 19 Apr 2006 15:54:43 -0700 Subject: [IronPython] Speed test In-Reply-To: <785694cd0604191526u76be05aclc796996a4cc15229@mail.gmail.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E0285827E@df-foxhound-msg.exchange.corp.microsoft.com> I've opened a bug in our internal database to track the issue. I'm not sure when we'll get to looking at it just yet as it may be somewhat of an involved investigation. But at least we won't forget about it. If you could give us something that was nice and self contained then we might be able to get to it sooner. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of JoeSox Sent: Wednesday, April 19, 2006 3:27 PM To: Discussion of IronPython Subject: Re: [IronPython] Speed test On 4/19/06, Dino Viehland wrote: > If in initializeDB you comment out: > > > ipEngine1.SetVariable("pred_file", predfile); ipEngine1.Execute(@"db.load_predicates_file(pred_file)"); > > does it get much faster? Yes, I received a time of 00:00:00.0156250 > If it doesn't then the problem is squarely an IronPython problem and we'll need to investigate further. > > The more static one has some issues... The GetObjectArray() call will be really expensive if your edges grow to be very big (it'll copy the array). Maybe that's what you need to do here though (and it looks like edge just grows unbounded as it never gets cleared). > Yes, in Python there are a couple of variable objects like "fw_edges" that grow into "" etc (but to me they resemble more like IronPython List object). > You also might be able to get rid of the Ops.GetEnumerator call for the Tuple, not that that should be very expensive though. > > NodesCollection is a StringCollection? Yes. > Also, are you taking your performance measurements at the console, or in an imported py file? Recently, I have been using an imported py file. I am about to start testing using the console. I have been using a custom Progressbar Form to notify the user of what was happening but I might try using a console for the same concept to see if it is any faster. > In general our performance is much better in imported files than it is at the console. > This is good to know but not always ideal. I am trying to write a Class Library to so any app can use it. -- Joseph _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From viola at microsoft.com Thu Apr 20 01:16:57 2006 From: viola at microsoft.com (Paul Viola) Date: Wed, 19 Apr 2006 16:16:57 -0700 Subject: [IronPython] IEnumerator in beta 5 In-Reply-To: Message-ID: <10073B83C89F804AABF10BD5F77AF081ABB277@RED-MSG-70.redmond.corp.microsoft.com> I have written some code (see below) to try to construct enumerators which can be used in other .NET code. I must be missing something here. I have not been able to create a class that inherits from IEnumerator and works in IP. The first class le_python is a python style iterator... it works. The second class le_ienumerator is code which is trying to construct an IEnumerator. Note it does not work. The third class le_python_ienumerator is a wild stab at something that might work (a python style iterator that inherits from IEnumerator). Note, even though the code is the same as the first class, it no longer works because of the inheritance (interesting). $ ./IronPythonConsole.exe -E IronPython 1.0.2300 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import test >>> [e for e in test.le_python([1, 2, 3])] [1, 2, 3] >>> [e for e in test.le_python_ienumerator([1, 2, 3])] Traceback (most recent call last): File , line 0, in input##17 AttributeError: 'le_python_ienumerator' object has no attribute 'MoveNext' >>> [e for e in test.le_ienumerator([1, 2, 3])] Traceback (most recent call last): File , line 0, in input##18 AttributeError: 'le_ienumerator' object has no attribute 'get_Current' >>> import System import System.Collections from sho import * class le_python: def __init__(self,obj): self.obj = obj self.ctr = -1 def __iter__(self): return self def next(self): if self.ctr >= self.obj.__len__()-1: raise StopIteration self.ctr = self.ctr+1 return self.obj[self.ctr] class le_ienumerator(System.Collections.IEnumerator): def __init__(self,obj): self.obj = obj self.ctr = -1 def Reset(self): self.ctr = -1 def MoveNext(self): if self.ctr >= self.obj.__len__()-1: return False self.ctr = self.ctr+1 return True def get_Current(self): return self.obj[self.ctr] class le_python_ienumerator(System.Collections.IEnumerator): def __init__(self,obj): self.obj = obj self.ctr = -1 def __iter__(self): return self def next(self): if self.ctr >= self.obj.__len__()-1: raise StopIteration self.ctr = self.ctr+1 return self.obj[self.ctr] -------------- next part -------------- An HTML attachment was scrubbed... URL: From joesox at gmail.com Thu Apr 20 07:27:44 2006 From: joesox at gmail.com (JoeSox) Date: Wed, 19 Apr 2006 22:27:44 -0700 Subject: [IronPython] Speed test In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E0285827E@df-foxhound-msg.exchange.corp.microsoft.com> References: <785694cd0604191526u76be05aclc796996a4cc15229@mail.gmail.com> <4039D552ADAB094BB1EA670F3E96214E0285827E@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <785694cd0604192227yd8831ceg2315cf4459c578da@mail.gmail.com> On 4/19/06, Dino Viehland wrote: > I've opened a bug in our internal database to track the issue. I'm not sure when we'll get to looking at it just yet as it may be somewhat of an involved investigation. But at least we won't forget about it. > > If you could give us something that was nice and self contained then we might be able to get to it sooner. > Ok great. I think this will work. Here are the two files you will need: http://joeswammi.com/projects/CNUDB.py http://joeswammi.com/projects/machine_All.txt ==== CNUDB.py is class ConceptNetDB with a test I added when the module is run in Python if __name__ == '__main__': c = ConceptNetDB() print '\n***** INITIALIZING ******' print '*************************\n' time1=time.time() c.load_predicates_file('E:\machine_All.txt') time2=time.time() print "-- test took",str(round(time2-time1,2)),'seconds. --\n' ==== ==== machine_All.txt is a file with 631 predicate lines ==== ==== Next, here is a click event I executed composed in MS Visual C# 2005 Express on an Athlon64 2.19ghz 512mb RAM laptop... private void button4_Click(object sender, EventArgs e) { PythonEngine ipEngine1 = new PythonEngine(); //IronPython... ipEngine1.Execute("import sys"); ipEngine1.Execute("sys.path.append('E:\')"); ipEngine1.Execute("import CNUDB"); ipEngine1.Execute("db=CNUDB.ConceptNetDB()"); DateTime time1 = new DateTime(); DateTime time2 = new DateTime(); time1 = DateTime.Now; ipEngine1.Execute(@"db.load_predicates_file('E:\machine_All.txt')"); time2 = DateTime.Now; MessageBox.Show(Convert.ToString(time2.Subtract(time1))); } ==== **** Results from MS Visual C# 2005 Express **** ran 5 times = {.250, .078, .093, .109, .078} seconds sum = .608 **** **** Results from IDLE 1.1.2 ran 5 times = {.03, .03, .03, .05, .03} seconds sum = .008 **** **** Results from Wing IDE 2.1 ran 5 times = {.05, .05, .05, .05, .05} seconds sum = .025 **** I am not sure how to run it in IronPythonConsole.exe And a side note, if you can this example creates some interesting objects like c.bw_edges and c.fw_edges. I believe at one time I was able to .GetVariable c.fw_edges into a System.Object or maybe I couldn't because of how dynamic these objects become. For example, if I am interpreting correctly c.bw_edges become dictionaries; the have Keys with Lists as values. -- Joseph From sanxiyn at gmail.com Thu Apr 20 09:04:07 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Thu, 20 Apr 2006 16:04:07 +0900 Subject: [IronPython] Multiple-inheritance with builtin types Message-ID: <5b0248170604200004i6beebb6bod61b1a4fc7be84cc@mail.gmail.com> Example code: class CompatMixin: def __getattr__(self, attr): if attr == 'string': return self else: raise AttributeError, attr class CompatString(str, CompatMixin): pass s = CompatString('abc') print s print s.string s.error The intent is to provide backward-compatibility with previous API, so that using the string as s and s.string both work. Above code was modelled after similar code in BeautifulSoup, a popular Python library. IronPython says: NotImplementedError: CompatString: unsupported base type for new-style class: IronPython.Runtime.ExtensibleString Seo Sanghyeon From vamshi.raghu at gmail.com Thu Apr 20 09:11:20 2006 From: vamshi.raghu at gmail.com (Vamshi Raghu) Date: Thu, 20 Apr 2006 03:11:20 -0400 Subject: [IronPython] System.Windows.Serialization Message-ID: Hello, Just wanted to let you know that LoadXaml in avalon.py in 1.0 Beta 5 imports System.Windows.Serialization, but this has been renamed from the Feb CTP of WinFX onwards to System.Windows.Markup. Had some trouble figuring it out! Still having trouble using LoadXaml though. It seems there is some incompatibility in the XAML expected by the deserializer. >>> xaml1 = LoadXaml("calc.xaml") Traceback (most recent call last): File , line 0, in input##14 File G:\Program Files\IronPython-1.0-Beta5\Tutorial\avalon.py, line 69, in Loa dXaml File PresentationFramework, line unknown, in Load File PresentationFramework, line unknown, in XmlTreeBuildDefault File PresentationFramework, line unknown, in Parse File PresentationFramework, line unknown, in ParseFragment File PresentationFramework, line unknown, in GetParseMode File PresentationFramework, line unknown, in ReadXaml File PresentationFramework, line unknown, in ParseError SystemError: 'Canvas' tag not valid in namespace ' http://schemas.microsoft.com/w infx/avalon/2005'. Tag names are case sensitive. Line '2' Position '2'. Also, it can't read files created from Expression Interactive Designer March CTP. I get errors like: >>> xaml1 = LoadXaml("D:\\Code\\C#\\Graph\\Scene1.xaml") Traceback (most recent call last): File , line 0, in input##16 File G:\Program Files\IronPython-1.0-Beta5\Tutorial\avalon.py, line 69, in LoadXaml File PresentationFramework, line unknown, in Load File PresentationFramework, line unknown, in XmlTreeBuildDefault File PresentationFramework, line unknown, in Parse File PresentationFramework, line unknown, in ParseFragment File PresentationFramework, line unknown, in GetParseMode File PresentationFramework, line unknown, in ReadXaml File PresentationFramework, line unknown, in ParseError SystemError: 'Class' attribute in ' http://schemas.microsoft.com/winfx/2006/xaml' namespace not valid. Try compiling the XAML. Line '9' Position '2'. Any hints? Version: IronPython 1.0.2296 (Beta) on .NET 2.0.50727.42 Windows SDK 5308.0 WinFX SDK 50215.45 Thanks! -Vamshi -------------- next part -------------- An HTML attachment was scrubbed... URL: From Detlef.Stute at al-lighting.com Thu Apr 20 14:21:58 2006 From: Detlef.Stute at al-lighting.com (Stute, Detlef ALRT/EEG4) Date: Thu, 20 Apr 2006 14:21:58 +0200 Subject: [IronPython] Line counter/ stop interpretation Message-ID: Hi, I'd like to use IP to run test sequences on a machine. My C# program will start a python file, which will do the tests. When the tests are running I'd like to update the program's desktop. So I'm looking for two features: - is it possible to get the current line counter from the python engine? ( to show this on the screen and give the user information about the progress) Sometimes a test needs a manual change on the equipment, so I like to pause the interpretation of the script. - Is it possible to pause ( not to interrupt) the interpretation process from a C# environment? Thank you Detlef Stute www.seatec-gmbh.com From Martin.Maly at microsoft.com Thu Apr 20 16:52:20 2006 From: Martin.Maly at microsoft.com (Martin Maly) Date: Thu, 20 Apr 2006 07:52:20 -0700 Subject: [IronPython] System.Windows.Serialization In-Reply-To: Message-ID: <5C0A6F919D675745BB1DBA7412DB68F502764E73@df-foxhound-msg.exchange.corp.microsoft.com> The WinFX is still undergoing changes that often result in the tutorial not working. We are actually resolving all these incompatibilities right now to make sure that the tutorial released with Beta 6 works with the February CTP of WinFX. As for possible differences between Feb CTP of WinFX and march CTP of the designer, that is a bit trickier and we'll probably have to wait for the two to work together again with subsequent releases of WinFX. Martin ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Vamshi Raghu Sent: Thursday, April 20, 2006 12:11 AM To: Discussion of IronPython Subject: [IronPython] System.Windows.Serialization Hello, Just wanted to let you know that LoadXaml in avalon.py in 1.0 Beta 5 imports System.Windows.Serialization, but this has been renamed from the Feb CTP of WinFX onwards to System.Windows.Markup. Had some trouble figuring it out! Still having trouble using LoadXaml though. It seems there is some incompatibility in the XAML expected by the deserializer. >>> xaml1 = LoadXaml("calc.xaml") Traceback (most recent call last): File , line 0, in input##14 File G:\Program Files\IronPython-1.0-Beta5\Tutorial\avalon.py, line 69, in Loa dXaml File PresentationFramework, line unknown, in Load File PresentationFramework, line unknown, in XmlTreeBuildDefault File PresentationFramework, line unknown, in Parse File PresentationFramework, line unknown, in ParseFragment File PresentationFramework, line unknown, in GetParseMode File PresentationFramework, line unknown, in ReadXaml File PresentationFramework, line unknown, in ParseError SystemError: 'Canvas' tag not valid in namespace ' http://schemas.microsoft.com/w infx/avalon/2005'. Tag names are case sensitive. Line '2' Position '2'. Also, it can't read files created from Expression Interactive Designer March CTP. I get errors like: >>> xaml1 = LoadXaml("D:\\Code\\C#\\Graph\\Scene1.xaml") Traceback (most recent call last): File , line 0, in input##16 File G:\Program Files\IronPython-1.0-Beta5\Tutorial\avalon.py, line 69, in LoadXaml File PresentationFramework, line unknown, in Load File PresentationFramework, line unknown, in XmlTreeBuildDefault File PresentationFramework, line unknown, in Parse File PresentationFramework, line unknown, in ParseFragment File PresentationFramework, line unknown, in GetParseMode File PresentationFramework, line unknown, in ReadXaml File PresentationFramework, line unknown, in ParseError SystemError: 'Class' attribute in ' http://schemas.microsoft.com/winfx/2006/xaml' namespace not valid. Try compiling the XAML. Line '9' Position '2'. Any hints? Version: IronPython 1.0.2296 (Beta) on .NET 2.0.50727.42 Windows SDK 5308.0 WinFX SDK 50215.45 Thanks! -Vamshi -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Thu Apr 20 17:13:05 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 20 Apr 2006 08:13:05 -0700 Subject: [IronPython] Multiple-inheritance with builtin types In-Reply-To: <5b0248170604200004i6beebb6bod61b1a4fc7be84cc@mail.gmail.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E028DBE56@df-foxhound-msg.exchange.corp.microsoft.com> Thanks for the report. This is another issue we've already fixed for beta 6 - inheriting from a mix of new-style classes as well as old-style classes. This was part of a large cleanup around __metaclass__ defined at the module scope, support for __metaclass__ being a function, support for __mro__ on new-style classes, and some random other fixes for more CPython compatibility. So you should be seeing this fix real soon now. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sanghyeon Seo Sent: Thursday, April 20, 2006 12:04 AM To: Discussion of IronPython Subject: [IronPython] Multiple-inheritance with builtin types Example code: class CompatMixin: def __getattr__(self, attr): if attr == 'string': return self else: raise AttributeError, attr class CompatString(str, CompatMixin): pass s = CompatString('abc') print s print s.string s.error The intent is to provide backward-compatibility with previous API, so that using the string as s and s.string both work. Above code was modelled after similar code in BeautifulSoup, a popular Python library. IronPython says: NotImplementedError: CompatString: unsupported base type for new-style class: IronPython.Runtime.ExtensibleString Seo Sanghyeon _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dans at houmus.org Thu Apr 20 17:59:07 2006 From: dans at houmus.org (Dan Shechter) Date: Thu, 20 Apr 2006 18:59:07 +0300 Subject: [IronPython] COM Interop / Dispose wierdness In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E0279A96B@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <006301c66493$63d2d750$424210ac@cartman> OK, I pretty much get what you're aiming for. You are saying that since there is no deterministic order for Finalization the COM object (which implements IWMMetaDataEditor) may be disposed of BEFORE my "Wrapper" Finalizer get's called. But shouldn't the order be enforced by someone (CLR that is) so that AT LEAST the managed components get finalized and destroyed BEFORE the unmanaged ones? I seem to remember there should be some thing like this... I'll dig deeper and also post in the WMF forums, Thanks, Shechter. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland Sent: Monday, April 17, 2006 18:24 To: Discussion of IronPython Subject: Re: [IronPython] COM Interop / Dispose wierdness This could be an order of finalization issue - if you let things shut down entirely then all the finalizers in the system would be eligible to be run at once. But if you dispose of the MetadataEditor by hand anything it depends upon won't have its finalizer run yet. At shutdown time the CLR will run all remaining finalizers and we could be cleaning up in the "wrong" order (although there's really no right order, finalization is non-deterministic). I think you'd need to talk to the WMF SDK team about the issue as they'll understand better their finalization issues (or wrap dispose in a try/catch InvalidCastException block :) ). Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F 0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dan Shechter Sent: Monday, April 17, 2006 3:38 AM To: 'Discussion of IronPython' Subject: [IronPython] COM Interop / Dispose wierdness Hi, I have a c# class which is a wrapper around the WMF (Windows Media Format) SDK. One of the classes, which wraps the IWMMetadataEditor interface roughly looks like this: namespace WMFSDKWrapper { public class MetadataEditor : IDisposable, IEnumerable { bool isDisposed = false; private IWMMetadataEditor editor; ... public void Flush() { editor.Flush(); } private void Dispose(bool disposing) { if (!isDisposed) { if (disposing) ; // No managed resources to clear up... // Clear up unmanaged resources Flush(); } isDisposed = true; } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } ~MetadataEditor() { Dispose(false); } } } Now, the wrapper (which obviously has more code) works perfectly. I can change a WM file's metadata or query it as I wish. I can call the Flush(), Close() or even Dispose() method directly and they all work fine... i.e.: If I call the Dispose() method "manually" I get: IronPython 1.0.2281 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import wmf >>> m = wmf.MetadataEditor("a.wma") >>> m[wmf.MediaMetadata.Title] '123' >>> m.Dispose() >>> ^Z (IronPythonConsole.exe exits cleanly) The problem I'm getting is that if exit the IronPython console without calling the object's Dispose method beforehand I get Something like this, regardless of what I did with the COM object (i.e., read-only or read-write): IronPython 1.0.2281 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import wmf >>> m = wmf.MetadataEditor("a.wma") >>> m[wmf.MediaMetadata.Title] '123' >>> ^Z Unhandled exception: Traceback (most recent call last): File WMFSDKWrapper, line unknown, in Finalize File WMFSDKWrapper, line unknown, in Dispose File WMFSDKWrapper, line unknown, in Flush File WMFSDKWrapper, line unknown, in Flush TypeError: Unable to cast COM object of type 'System.__ComObject' to interface type 'WMFSDKWrapper.IWMMetadataEditor'. T his operation failed because the QueryInterface call on the COM component for the interface with IID '{96406BD9-2B2B-11D 3-B36B-00C04F6108FF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). Unhandled Exception: System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface ty pe 'WMFSDKWrapper.IWMMetadataEditor'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{96406BD9-2B2B-11D3-B36B-00C04F6108FF}' failed due to the following error: No such interface suppor ted (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). at WMFSDKWrapper.IWMMetadataEditor.Flush() at WMFSDKWrapper.MetadataEditor.Flush() at WMFSDKWrapper.MetadataEditor.Dispose(Boolean disposing) at WMFSDKWrapper.MetadataEditor.Finalize() Any ideas? Shechter. _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From joesox at gmail.com Thu Apr 20 19:28:27 2006 From: joesox at gmail.com (JoeSox) Date: Thu, 20 Apr 2006 10:28:27 -0700 Subject: [IronPython] Speed test In-Reply-To: <785694cd0604192227yd8831ceg2315cf4459c578da@mail.gmail.com> References: <785694cd0604191526u76be05aclc796996a4cc15229@mail.gmail.com> <4039D552ADAB094BB1EA670F3E96214E0285827E@df-foxhound-msg.exchange.corp.microsoft.com> <785694cd0604192227yd8831ceg2315cf4459c578da@mail.gmail.com> Message-ID: <785694cd0604201028r60484797r4622ea4cc506b8a@mail.gmail.com> Ok, I had enough time to test this in IronPythonConsole.exe.... IronPython 1.0.2280 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import sys,time >>> sys.path.append('E:\\') >>> import CNUDB >>> file = 'E:\\machine_All.txt' >>> def test(thefile): ... c = CNUDB.ConceptNetDB() ... time1=time.time() ... c.load_predicates_file(thefile) ... time2=time.time() ... print "-- test took",str(round(time2-time1,2)),'seconds. --\n' ... >>> test(file) -- test took 0.28 seconds. -- >>> test(file) -- test took 0.09 seconds. -- >>> test(file) -- test took 0.09 seconds. -- >>> test(file) -- test took 0.09 seconds. -- >>> test(file) -- test took 0.09 seconds. -- >>> sum=.64 This test was run on a different machine then the laptop. Pentium4 3ghz 512 RAM -- Joseph On 4/19/06, JoeSox wrote: > On 4/19/06, Dino Viehland wrote: > > I've opened a bug in our internal database to track the issue. I'm not sure when we'll get to looking at it just yet as it may be somewhat of an involved investigation. But at least we won't forget about it. > > > > If you could give us something that was nice and self contained then we might be able to get to it sooner. > > > > Ok great. I think this will work. Here are the two files you will need: > http://joeswammi.com/projects/CNUDB.py > http://joeswammi.com/projects/machine_All.txt > > ==== > CNUDB.py is class ConceptNetDB with a test I added when the module is > run in Python > if __name__ == '__main__': > c = ConceptNetDB() > print '\n***** INITIALIZING ******' > print '*************************\n' > time1=time.time() > c.load_predicates_file('E:\machine_All.txt') > time2=time.time() > print "-- test took",str(round(time2-time1,2)),'seconds. --\n' > ==== > ==== > machine_All.txt is a file with 631 predicate lines > ==== > ==== > Next, here is a click event I executed composed in MS Visual C# 2005 > Express on an Athlon64 2.19ghz 512mb RAM laptop... > private void button4_Click(object sender, EventArgs e) > { > PythonEngine ipEngine1 = new PythonEngine(); > //IronPython... > ipEngine1.Execute("import sys"); > ipEngine1.Execute("sys.path.append('E:\')"); > ipEngine1.Execute("import CNUDB"); > ipEngine1.Execute("db=CNUDB.ConceptNetDB()"); > DateTime time1 = new DateTime(); > DateTime time2 = new DateTime(); > time1 = DateTime.Now; > ipEngine1.Execute(@"db.load_predicates_file('E:\machine_All.txt')"); > time2 = DateTime.Now; > MessageBox.Show(Convert.ToString(time2.Subtract(time1))); > } > ==== > > **** Results from MS Visual C# 2005 Express **** > ran 5 times = {.250, .078, .093, .109, .078} seconds > sum = .608 > **** > > **** Results from IDLE 1.1.2 > ran 5 times = {.03, .03, .03, .05, .03} seconds > sum = .008 > **** > > **** Results from Wing IDE 2.1 > ran 5 times = {.05, .05, .05, .05, .05} seconds > sum = .025 > **** > > I am not sure how to run it in IronPythonConsole.exe > > And a side note, if you can this example creates some interesting > objects like c.bw_edges and c.fw_edges. I believe at one time I was > able to .GetVariable c.fw_edges into a System.Object or maybe I > couldn't because of how dynamic these objects become. For example, if > I am interpreting correctly c.bw_edges become dictionaries; the have > Keys with Lists as values. > -- > Joseph From joesox at gmail.com Thu Apr 20 19:35:17 2006 From: joesox at gmail.com (JoeSox) Date: Thu, 20 Apr 2006 10:35:17 -0700 Subject: [IronPython] Speed test In-Reply-To: <785694cd0604201028r60484797r4622ea4cc506b8a@mail.gmail.com> References: <785694cd0604191526u76be05aclc796996a4cc15229@mail.gmail.com> <4039D552ADAB094BB1EA670F3E96214E0285827E@df-foxhound-msg.exchange.corp.microsoft.com> <785694cd0604192227yd8831ceg2315cf4459c578da@mail.gmail.com> <785694cd0604201028r60484797r4622ea4cc506b8a@mail.gmail.com> Message-ID: <785694cd0604201035t62de095ela2919e16cd9f6d54@mail.gmail.com> It was late for me when I composed this last night. So some corrections are in order... > On 4/19/06, JoeSox wrote: > > **** Results from IDLE 1.1.2 > > ran 5 times = {.03, .03, .03, .05, .03} seconds > > sum = .008 > > **** sum = .17 > > **** Results from Wing IDE 2.1 > > ran 5 times = {.05, .05, .05, .05, .05} seconds > > sum = .025 > > **** sum = .25 -- Joseph From dinov at exchange.microsoft.com Thu Apr 20 18:14:44 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 20 Apr 2006 09:14:44 -0700 Subject: [IronPython] COM Interop / Dispose wierdness In-Reply-To: <006301c66493$63d2d750$424210ac@cartman> Message-ID: <4039D552ADAB094BB1EA670F3E96214E028DBEB2@df-foxhound-msg.exchange.corp.microsoft.com> Nope, no guaranteed order... The problem here is it could be a problem w/ the order of two unmanaged objects which are being "finalized" in some arbitrary order because the GC is cleaning them up. Another possibility that occurred to me is that there could be a violation of COM rules by WMF which the CLR only hits at shutdown. In particular I'm thinking of the aggregation rules where if you QI an object implementing IFoo for interface IBar and it succeeds then QIing IBar for IFoo must succeed. I've recently been told that the CLR cares about objects following this rule a lot, so maybe you hit this at shutdown but not at runtime. But again, it's a WMF issue :) Hopefully you'll have good luck w/ the WMF forums. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dan Shechter Sent: Thursday, April 20, 2006 8:59 AM To: 'Discussion of IronPython' Subject: Re: [IronPython] COM Interop / Dispose wierdness OK, I pretty much get what you're aiming for. You are saying that since there is no deterministic order for Finalization the COM object (which implements IWMMetaDataEditor) may be disposed of BEFORE my "Wrapper" Finalizer get's called. But shouldn't the order be enforced by someone (CLR that is) so that AT LEAST the managed components get finalized and destroyed BEFORE the unmanaged ones? I seem to remember there should be some thing like this... I'll dig deeper and also post in the WMF forums, Thanks, Shechter. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland Sent: Monday, April 17, 2006 18:24 To: Discussion of IronPython Subject: Re: [IronPython] COM Interop / Dispose wierdness This could be an order of finalization issue - if you let things shut down entirely then all the finalizers in the system would be eligible to be run at once. But if you dispose of the MetadataEditor by hand anything it depends upon won't have its finalizer run yet. At shutdown time the CLR will run all remaining finalizers and we could be cleaning up in the "wrong" order (although there's really no right order, finalization is non-deterministic). I think you'd need to talk to the WMF SDK team about the issue as they'll understand better their finalization issues (or wrap dispose in a try/catch InvalidCastException block :) ). Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F 0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dan Shechter Sent: Monday, April 17, 2006 3:38 AM To: 'Discussion of IronPython' Subject: [IronPython] COM Interop / Dispose wierdness Hi, I have a c# class which is a wrapper around the WMF (Windows Media Format) SDK. One of the classes, which wraps the IWMMetadataEditor interface roughly looks like this: namespace WMFSDKWrapper { public class MetadataEditor : IDisposable, IEnumerable { bool isDisposed = false; private IWMMetadataEditor editor; ... public void Flush() { editor.Flush(); } private void Dispose(bool disposing) { if (!isDisposed) { if (disposing) ; // No managed resources to clear up... // Clear up unmanaged resources Flush(); } isDisposed = true; } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } ~MetadataEditor() { Dispose(false); } } } Now, the wrapper (which obviously has more code) works perfectly. I can change a WM file's metadata or query it as I wish. I can call the Flush(), Close() or even Dispose() method directly and they all work fine... i.e.: If I call the Dispose() method "manually" I get: IronPython 1.0.2281 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import wmf >>> m = wmf.MetadataEditor("a.wma") >>> m[wmf.MediaMetadata.Title] '123' >>> m.Dispose() >>> ^Z (IronPythonConsole.exe exits cleanly) The problem I'm getting is that if exit the IronPython console without calling the object's Dispose method beforehand I get Something like this, regardless of what I did with the COM object (i.e., read-only or read-write): IronPython 1.0.2281 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import wmf >>> m = wmf.MetadataEditor("a.wma") >>> m[wmf.MediaMetadata.Title] '123' >>> ^Z Unhandled exception: Traceback (most recent call last): File WMFSDKWrapper, line unknown, in Finalize File WMFSDKWrapper, line unknown, in Dispose File WMFSDKWrapper, line unknown, in Flush File WMFSDKWrapper, line unknown, in Flush TypeError: Unable to cast COM object of type 'System.__ComObject' to interface type 'WMFSDKWrapper.IWMMetadataEditor'. T his operation failed because the QueryInterface call on the COM component for the interface with IID '{96406BD9-2B2B-11D 3-B36B-00C04F6108FF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). Unhandled Exception: System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface ty pe 'WMFSDKWrapper.IWMMetadataEditor'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{96406BD9-2B2B-11D3-B36B-00C04F6108FF}' failed due to the following error: No such interface suppor ted (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). at WMFSDKWrapper.IWMMetadataEditor.Flush() at WMFSDKWrapper.MetadataEditor.Flush() at WMFSDKWrapper.MetadataEditor.Dispose(Boolean disposing) at WMFSDKWrapper.MetadataEditor.Finalize() Any ideas? Shechter. _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From joesox at gmail.com Thu Apr 20 23:08:41 2006 From: joesox at gmail.com (JoeSox) Date: Thu, 20 Apr 2006 14:08:41 -0700 Subject: [IronPython] Speed test In-Reply-To: <785694cd0604201028r60484797r4622ea4cc506b8a@mail.gmail.com> References: <785694cd0604191526u76be05aclc796996a4cc15229@mail.gmail.com> <4039D552ADAB094BB1EA670F3E96214E0285827E@df-foxhound-msg.exchange.corp.microsoft.com> <785694cd0604192227yd8831ceg2315cf4459c578da@mail.gmail.com> <785694cd0604201028r60484797r4622ea4cc506b8a@mail.gmail.com> Message-ID: <785694cd0604201408m69049221ib60a7dbe454d00fe@mail.gmail.com> I completed one more IronPythonConsole.exe test. I added the below method to CNUDB.py === def test(self,thefile): time1=time.time() self.load_predicates_file(thefile) time2=time.time() print "-- test took",str(round(time2-time1,2)),'seconds. --\n' === The results were a little better but I haven't thought about what all this means as far as how to design my ConceptNet 2.1 Class Library. But are are the results (from a Pentium4 3ghz 512RAM) for anyone who is following this thread: ===== IronPython 1.0.2280 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import sys,time >>> sys.path.append('E:\\') >>> import CNUDB >>> cn=CNUDB.ConceptNetDB() >>> cn.test('E:\\machine_All.txt') -- test took 0.37 seconds. -- >>> cn.test('E:\\machine_All.txt') -- test took 0.08 seconds. -- >>> cn.test('E:\\machine_All.txt') -- test took 0.06 seconds. -- >>> cn.test('E:\\machine_All.txt') -- test took 0.06 seconds. -- >>> cn.test('E:\\machine_All.txt') -- test took 0.06 seconds. -- >>> ===== sum = .63 Almost the same .64 result as my first IronPythonConsole test. So I am still trying to get close to IDLE 1.1.2's 0.17 seconds result. -- Joseph On 4/20/06, JoeSox wrote: > > Ok great. I think this will work. Here are the two files you will need: > > http://joeswammi.com/projects/CNUDB.py > > http://joeswammi.com/projects/machine_All.txt From dinov at exchange.microsoft.com Fri Apr 21 02:15:30 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 20 Apr 2006 17:15:30 -0700 Subject: [IronPython] IronPython 1.0 Beta 6 Message-ID: <4039D552ADAB094BB1EA670F3E96214E028DC52E@df-foxhound-msg.exchange.corp.microsoft.com> Hello IronPython Community, We have just released IronPython 1.0 Beta 6. This release focuses primarily on fixing bugs and improving compatibility with CPython. Major cleanups includes supporting __metaclass__ at the module level, using __mro__ for new-style class method resolution, and a massive cleanup to make sure all of our comparisons are identical to CPython. With this release we've also improved the performance of calls to arbitrary .NET assemblies by enabling our call-optimization for all assemblies and updated the tutorial for beta 6. One change that has the potential to break people in beta 6 is that we are deprecating clr.Path and instead suggesting everyone switch over to using sys.path instead. This is more inline with how CPython searches for .pyd extension files and we believe will simplify the loading story. This also means that the current working directory will be included in the search path by default which seems to have been an issue that caused many problems. In this release of IronPython we've introduced a breaking change concerning the treatment of .NET value types. We'd like to elicit your feedback on this change to determine if it needs tweaking or outright changes prior to a V1.0 release. You can read more about this specific change at http://channel9.msdn.com/wiki/default.aspx/IronPython.ValueTypes A more complete list of changes follows at the end. You can download the release from: http://www.microsoft.com/downloads/details.aspx?FamilyId=F5BB7DEF-7C71-40D0-9AD7-81E60E85E3DB&displaylang=en We'd like to thank everyone in the community for your bug reports and suggestions that helped make this a better release: Andrzej Krzywda, Erin Renshaw, John Platt, Jonathan Jacobs, Mat Steeples, Mathew Yeates, Nathan R. Ernst, Nichlas Jacobson, Richard Hsu, Seo Sanghyeon, Stanpinte, Szymon Kobalczyk, Tragic_hip, William Reade. Thanks and keep in touch, The IronPython Team More complete list of changes and bug fixes: ============================================ Fixed precision formatting bugs in string formatting Enable ReflectOptimization for all assemblies and methods (improve .NET function call performance) Add update and other missing functionality to module & class dictionaries Fixed bugs in list comprehension code gen Implemented -W (warning filters) command line parameter Improve IronPython test suites ability to run on both IronPython & CPython Able to run test_list from standard CPython library distribution (w/ 2 tests disabled) Fix equality check in if statements Cleanup semantic issues in IronPython code base Fix tabs to align at offset of 8 rather than incrementing by 8 Add Line information to PythonSyntaxError Fix for x in d.keys() at console not raising syntax error Fix repr / str results on old class to match CPython Fix > 5 arg case for calling optimized functions w/ params Make sys.exc_traceback a writeable attribute Add __mro__ for new-style classes and use it for method resolution Add support for __metaclass__ defined at the module scope Enable inheritance from both new-style classes and old-style classes Prevent subclassing from the same type twice Enforce inheritance restrictions for MRO. Can now run test_slice unchanged from CPython standard library regressions Add running test_xrange from CPython standard library regressions Disable useless assignment to mutable value types Console end-of-input detection cleaned up Bugfix: sgmllib still not compiling (re module bug) Implement popen in os module, and other functionality as well Bugfix: File object lacks closed attribute Add support for creating file from .NET stream w/ mode Bugfix: File object lacks tell method Bugfix: loading a py file crashes winforms (race in winforms.py) Fix RemoveRange in conversion wrappers Bugfix: IronPython lets you delete builtin functions by specifying the name Support getting CLR type object from Python type object (clr.GetClrType) Bugfix: Assigning or Deleting events should throw a TypeError exception Bugfix: selfmodifyingComparison in list.sort Bugfix: Match CPython 2.4 behavior for base64.b64decode Fix IndexOf bugs that can result in IndexOutOfRangeExceptions in conversion wrappers Bugfix: enable deriving from complex Bugfix: leading space sometimes not reported as a syntax error Bugfix: False == None ? More FxCop cleanup Move rarely used object dictionaries into SymbolId dictionary Enable access to CLI assemblies & namespaces via __dict__ Bugfix: generation of RealEntryPoint in CodeDom Bugfix: CodeDom no newline afer def of _ConstructorFieldInitFunction leading to parsing errors Bugfix: CodeDom: Empty try blocks not handled correctly Bugfix: CodeDom: Emitting a try with multiple except clauses aligns indentations incorrectly Bugfix: COM import does not iterate over interfaces Add COM interop test harness Bugfix: Types don't evaluate to True, instead they throw Bugfix: reg ex differs from CPython (matching & groups) Fix filename shown in file Fix bug in startswith Improve error message in XRange.AddSequence/MultiplySequence Improve error checking on function calls Add large number of compatibility tests for comparisons of built-in types, new-style and old-style classes Bugfix: Fix CodeDom generation & round tripping of fields w/ init expressions Bugfix: Fix CodeDom resolution of private methods Improve testing of console Bugfix: CodeDom IterationStatement parsing and generation is broken Bugfix: CodeDom CodeConditionStatement parsing w/ non-null FalseStatements is broken Bugfix: Fix some issues w/ empty blocks in CodeDom Bugfix: ReflectedNamespace.DeleteAttr wasn't working correctly & other object ID keys fixed Fix ArrayOps issues Enable use of instance operators defined from C++/CLI Fix StackOverflow when calling Ops methods Bugfix: Fix handling of unmappable Unicode characters in CodeDom Bugfix: Invalid generation of CodePrimitiveExpressions for single chars Bugfix: Fix MulticallGenerator issues Improve thread safety of IronPython Improve & fix issues in IronPython Tutorial Bugfix: ReflectOptimizer doesn't call Ops.ToPython Implement sys.setrecursionlimit and set default recursion limit to unlimited Fix CodeDom support for using a TextReader Improve stack trace shown after keyboard interrupt Support in-memory compilation in CodeDom Remove clr.Path and use sys.path for assembly loading Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -------------- next part -------------- An HTML attachment was scrubbed... URL: From joesox at gmail.com Fri Apr 21 03:25:48 2006 From: joesox at gmail.com (JoeSox) Date: Thu, 20 Apr 2006 18:25:48 -0700 Subject: [IronPython] IronPython 1.0 Beta 6 In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E028DC52E@df-foxhound-msg.exchange.corp.microsoft.com> References: <4039D552ADAB094BB1EA670F3E96214E028DC52E@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <785694cd0604201825x61e7ca43s939868a746e4f9b2@mail.gmail.com> Dino, When I rebuild my project referencing beta6 dll I received Error 6 'IronPython.Runtime.List' does not contain a definition for 'append' -- Joseph From joesox at gmail.com Fri Apr 21 03:30:11 2006 From: joesox at gmail.com (JoeSox) Date: Thu, 20 Apr 2006 18:30:11 -0700 Subject: [IronPython] IronPython 1.0 Beta 6 In-Reply-To: <785694cd0604201825x61e7ca43s939868a746e4f9b2@mail.gmail.com> References: <4039D552ADAB094BB1EA670F3E96214E028DC52E@df-foxhound-msg.exchange.corp.microsoft.com> <785694cd0604201825x61e7ca43s939868a746e4f9b2@mail.gmail.com> Message-ID: <785694cd0604201830g10e9426cx15bbf5e5f618bbff@mail.gmail.com> Ok, looks like its now .Append? lol :) On 4/20/06, JoeSox wrote: > Dino, > > When I rebuild my project referencing beta6 dll I received > Error 6 'IronPython.Runtime.List' does not contain a definition for 'append' > > > -- > Joseph From dinov at exchange.microsoft.com Fri Apr 21 03:36:42 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 20 Apr 2006 18:36:42 -0700 Subject: [IronPython] IronPython 1.0 Beta 6 In-Reply-To: <785694cd0604201830g10e9426cx15bbf5e5f618bbff@mail.gmail.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E028DC5E3@df-foxhound-msg.exchange.corp.microsoft.com> Yeah, that's part of the FxCop cleanup - internally all of our methods should be named using the .NET naming guidelines, and we expose them out to Python via a PythonName attribute that gives it the name "append". Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of JoeSox Sent: Thursday, April 20, 2006 6:30 PM To: Discussion of IronPython Subject: Re: [IronPython] IronPython 1.0 Beta 6 Ok, looks like its now .Append? lol :) On 4/20/06, JoeSox wrote: > Dino, > > When I rebuild my project referencing beta6 dll I received > Error 6 'IronPython.Runtime.List' does not contain a definition for 'append' > > > -- > Joseph _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From vamshi.raghu at gmail.com Fri Apr 21 03:50:06 2006 From: vamshi.raghu at gmail.com (Vamshi Raghu) Date: Thu, 20 Apr 2006 21:50:06 -0400 Subject: [IronPython] System.Windows.Serialization In-Reply-To: <5C0A6F919D675745BB1DBA7412DB68F502764E73@df-foxhound-msg.exchange.corp.microsoft.com> References: <5C0A6F919D675745BB1DBA7412DB68F502764E73@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: Yay! The calc.xaml loads with Beta 6. I think the EID issue maybe something else altogether. Thanks! -Vamshi On 4/20/06, Martin Maly wrote: > > The WinFX is still undergoing changes that often result in the tutorial > not working. We are actually resolving all these incompatibilities right now > to make sure that the tutorial released with Beta 6 works with the February > CTP of WinFX. As for possible differences between Feb CTP of WinFX and march > CTP of the designer, that is a bit trickier and we'll probably have to wait > for the two to work together again with subsequent releases of WinFX. > > > > Martin > > > ------------------------------ > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Vamshi Raghu > *Sent:* Thursday, April 20, 2006 12:11 AM > *To:* Discussion of IronPython > *Subject:* [IronPython] System.Windows.Serialization > > > > Hello, > > Just wanted to let you know that LoadXaml in avalon.py in 1.0 Beta 5 > imports System.Windows.Serialization, but this has been renamed from the > Feb CTP of WinFX onwards to System.Windows.Markup. > > Had some trouble figuring it out! Still having trouble using LoadXaml > though. It seems there is some incompatibility in the XAML expected by the > deserializer. > > >>> xaml1 = LoadXaml("calc.xaml") > Traceback (most recent call last): > File , line 0, in input##14 > File G:\Program Files\IronPython-1.0-Beta5\Tutorial\avalon.py, line 69, > in Loa > dXaml > File PresentationFramework, line unknown, in Load > File PresentationFramework, line unknown, in XmlTreeBuildDefault > File PresentationFramework, line unknown, in Parse > File PresentationFramework, line unknown, in ParseFragment > File PresentationFramework, line unknown, in GetParseMode > File PresentationFramework, line unknown, in ReadXaml > File PresentationFramework, line unknown, in ParseError > SystemError: 'Canvas' tag not valid in namespace ' > http://schemas.microsoft.com/w > infx/avalon/2005'. Tag names are case sensitive. Line '2' Position '2'. > > Also, it can't read files created from Expression Interactive Designer > March CTP. I get errors like: > >>> xaml1 = LoadXaml("D:\\Code\\C#\\Graph\\Scene1.xaml") > Traceback (most recent call last): > File , line 0, in input##16 > File G:\Program Files\IronPython-1.0-Beta5\Tutorial\avalon.py, line 69, > in LoadXaml > File PresentationFramework, line unknown, in Load > File PresentationFramework, line unknown, in XmlTreeBuildDefault > File PresentationFramework, line unknown, in Parse > File PresentationFramework, line unknown, in ParseFragment > File PresentationFramework, line unknown, in GetParseMode > File PresentationFramework, line unknown, in ReadXaml > File PresentationFramework, line unknown, in ParseError > SystemError: 'Class' attribute in ' > http://schemas.microsoft.com/winfx/2006/xaml' > namespace not valid. Try compiling the XAML. Line '9' Position '2'. > > Any hints? > > Version: > IronPython 1.0.2296 (Beta) on .NET 2.0.50727.42 > Windows SDK 5308.0 > WinFX SDK 50215.45 > > Thanks! > -Vamshi > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joesox at gmail.com Fri Apr 21 04:13:16 2006 From: joesox at gmail.com (JoeSox) Date: Thu, 20 Apr 2006 19:13:16 -0700 Subject: [IronPython] Speed test In-Reply-To: <785694cd0604201408m69049221ib60a7dbe454d00fe@mail.gmail.com> References: <785694cd0604191526u76be05aclc796996a4cc15229@mail.gmail.com> <4039D552ADAB094BB1EA670F3E96214E0285827E@df-foxhound-msg.exchange.corp.microsoft.com> <785694cd0604192227yd8831ceg2315cf4459c578da@mail.gmail.com> <785694cd0604201028r60484797r4622ea4cc506b8a@mail.gmail.com> <785694cd0604201408m69049221ib60a7dbe454d00fe@mail.gmail.com> Message-ID: <785694cd0604201913xed0e0a2xcc0bf11dae4b0ef0@mail.gmail.com> ok, retested using beta6: C# previously referenced in this thread button4_Click() test: {.1875, .078125, .078125, .062500, .078125} sum = 0.484375 beats the previous beta5 sum of .608 IronPythonConsole test(file): {.03, .06, .05, .14, .05}* sum = .33 2nd run (new IronPythonConsole instance) {.17, .05, .05, .03, .06} sum = .36 *now this test was done on my laptop (not the same computer I ran this on earlier today not sure if that matters or not but I won't be able to run the test until Monday on that machine) Next, I just completed a run of my InitializeDB() method and it finished with a faster time of 00:03:08.9062500 Faster, then beta5's finish time of 00:04:40.4845 about a second and a half improvement but Python still clocks in at 52.907753 seconds. However, I need to perfom this same test(loading the three predicate files and creating the dictionaries) in IronPythonConsole. Keep up the good work! -- Joseph On 4/20/06, JoeSox wrote: > I completed one more IronPythonConsole.exe test. I added the below > method to CNUDB.py > === > def test(self,thefile): > time1=time.time() > self.load_predicates_file(thefile) > time2=time.time() > print "-- test took",str(round(time2-time1,2)),'seconds. --\n' > === > > The results were a little better but I haven't thought about what all > this means as far as how to design my ConceptNet 2.1 Class Library. > But are are the results (from a Pentium4 3ghz 512RAM) for anyone who > is following this thread: > ===== > IronPython 1.0.2280 (Beta) on .NET 2.0.50727.42 > Copyright (c) Microsoft Corporation. All rights reserved. > >>> import sys,time > >>> sys.path.append('E:\\') > >>> import CNUDB > >>> cn=CNUDB.ConceptNetDB() > >>> cn.test('E:\\machine_All.txt') > > -- test took 0.37 seconds. -- > > >>> cn.test('E:\\machine_All.txt') > > -- test took 0.08 seconds. -- > > >>> cn.test('E:\\machine_All.txt') > > -- test took 0.06 seconds. -- > > >>> cn.test('E:\\machine_All.txt') > > -- test took 0.06 seconds. -- > > >>> cn.test('E:\\machine_All.txt') > > -- test took 0.06 seconds. -- > > >>> > ===== > sum = .63 > > Almost the same .64 result as my first IronPythonConsole test. So I > am still trying to get close to IDLE 1.1.2's 0.17 seconds result. > -- > Joseph > > On 4/20/06, JoeSox wrote: > > > Ok great. I think this will work. Here are the two files you will need: > > > http://joeswammi.com/projects/CNUDB.py > > > http://joeswammi.com/projects/machine_All.txt From dinov at exchange.microsoft.com Fri Apr 21 04:16:37 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 20 Apr 2006 19:16:37 -0700 Subject: [IronPython] Speed test In-Reply-To: <785694cd0604201913xed0e0a2xcc0bf11dae4b0ef0@mail.gmail.com> References: <785694cd0604191526u76be05aclc796996a4cc15229@mail.gmail.com> <4039D552ADAB094BB1EA670F3E96214E0285827E@df-foxhound-msg.exchange.corp.microsoft.com> <785694cd0604192227yd8831ceg2315cf4459c578da@mail.gmail.com> <785694cd0604201028r60484797r4622ea4cc506b8a@mail.gmail.com> <785694cd0604201408m69049221ib60a7dbe454d00fe@mail.gmail.com>, <785694cd0604201913xed0e0a2xcc0bf11dae4b0ef0@mail.gmail.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E235C69@df-foxhound-msg.exchange.corp.microsoft.com> The speed improvements you're seeing here are likely the usage of our Reflect Optimizer for all C# methods now. This gives a huge speed improvement in the time it takes to call arbitrary C# code (previously we only optimized methods in IronPython, as the optimizer was not able to handle a large number of method signatures). But we still have a ways to go... ________________________________________ From: users-bounces at lists.ironpython.com On Behalf Of JoeSox Sent: Thursday, April 20, 2006 7:13 PM To: Discussion of IronPython Subject: Re: [IronPython] Speed test ok, retested using beta6: C# previously referenced in this thread button4_Click() test: {.1875, .078125, .078125, .062500, .078125} sum = 0.484375 beats the previous beta5 sum of .608 IronPythonConsole test(file): {.03, .06, .05, .14, .05}* sum = .33 2nd run (new IronPythonConsole instance) {.17, .05, .05, .03, .06} sum = .36 *now this test was done on my laptop (not the same computer I ran this on earlier today not sure if that matters or not but I won't be able to run the test until Monday on that machine) Next, I just completed a run of my InitializeDB() method and it finished with a faster time of 00:03:08.9062500 Faster, then beta5's finish time of 00:04:40.4845 about a second and a half improvement but Python still clocks in at 52.907753 seconds. However, I need to perfom this same test(loading the three predicate files and creating the dictionaries) in IronPythonConsole. Keep up the good work! -- Joseph On 4/20/06, JoeSox wrote: > I completed one more IronPythonConsole.exe test. I added the below > method to CNUDB.py > === > def test(self,thefile): > time1=time.time() > self.load_predicates_file(thefile) > time2=time.time() > print "-- test took",str(round(time2-time1,2)),'seconds. --\n' > === > > The results were a little better but I haven't thought about what all > this means as far as how to design my ConceptNet 2.1 Class Library. > But are are the results (from a Pentium4 3ghz 512RAM) for anyone who > is following this thread: > ===== > IronPython 1.0.2280 (Beta) on .NET 2.0.50727.42 > Copyright (c) Microsoft Corporation. All rights reserved. > >>> import sys,time > >>> sys.path.append('E:\\') > >>> import CNUDB > >>> cn=CNUDB.ConceptNetDB() > >>> cn.test('E:\\machine_All.txt') > > -- test took 0.37 seconds. -- > > >>> cn.test('E:\\machine_All.txt') > > -- test took 0.08 seconds. -- > > >>> cn.test('E:\\machine_All.txt') > > -- test took 0.06 seconds. -- > > >>> cn.test('E:\\machine_All.txt') > > -- test took 0.06 seconds. -- > > >>> cn.test('E:\\machine_All.txt') > > -- test took 0.06 seconds. -- > > >>> > ===== > sum = .63 > > Almost the same .64 result as my first IronPythonConsole test. So I > am still trying to get close to IDLE 1.1.2's 0.17 seconds result. > -- > Joseph > > On 4/20/06, JoeSox wrote: > > > Ok great. I think this will work. Here are the two files you will need: > > > http://joeswammi.com/projects/CNUDB.py > > > http://joeswammi.com/projects/machine_All.txt _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From smppms2002 at yahoo.com.cn Fri Apr 21 09:13:04 2006 From: smppms2002 at yahoo.com.cn (=?gb2312?q?=BA=FA=20=D1=EE?=) Date: Fri, 21 Apr 2006 15:13:04 +0800 (CST) Subject: [IronPython] time.strftime have different output in ironpython and python Message-ID: <20060421071304.67437.qmail@web15804.mail.cnb.yahoo.com> IronPython 1.0.60420 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import time >>> time.strftime("%x %X", time.localtime() ) u'21 \u4e0b' >>> ActivePython 2.3.5 Build 236 (ActiveState Corp.) based on Python 2.3.5 (#62, Feb 9 2005, 16:17:08) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import time >>> time.strftime("%x %X", time.localtime() ) '04/21/06 14:30:46' >>> --------------------------------- ??1G??????????? -------------- next part -------------- An HTML attachment was scrubbed... URL: From smppms2002 at yahoo.com.cn Fri Apr 21 09:15:23 2006 From: smppms2002 at yahoo.com.cn (=?gb2312?q?=BA=FA=20=D1=EE?=) Date: Fri, 21 Apr 2006 15:15:23 +0800 (CST) Subject: [IronPython] who is using ironpython in projects ? Message-ID: <20060421071523.68283.qmail@web15804.mail.cnb.yahoo.com> in python's web site, we can see a Success Stories link (http://www.python.org/about/success/), I wonder who is using ironpython in their project. --------------------------------- ??1G??????????? ????-????????? -------------- next part -------------- An HTML attachment was scrubbed... URL: From sanxiyn at gmail.com Fri Apr 21 09:26:46 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Fri, 21 Apr 2006 16:26:46 +0900 Subject: [IronPython] RE_Match.string Message-ID: <5b0248170604210026o35e383d4uc5c774c97af6e358@mail.gmail.com> # test.py import re print re.search('b', 'abc').string # CPython abc # IronPython b Seo Sanghyeon From sanxiyn at gmail.com Fri Apr 21 10:04:46 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Fri, 21 Apr 2006 17:04:46 +0900 Subject: [IronPython] Unable to view IronPython Tutorial image Message-ID: <5b0248170604210104o39f68848wa69bc683fb330c8c@mail.gmail.com> While reading Tutorial.htm, dialog2.jpg didn't load, because file was named dialog2.JPG (uppercase) in ZIP file. This causes a problem in case-sensitive file systems. Seo Sanghyeon From stan at phidani.be Fri Apr 21 11:15:19 2006 From: stan at phidani.be (Stanislas Pinte) Date: Fri, 21 Apr 2006 09:15:19 +0000 Subject: [IronPython] who is using ironpython in projects ? In-Reply-To: <20060421071523.68283.qmail@web15804.mail.cnb.yahoo.com> References: <20060421071523.68283.qmail@web15804.mail.cnb.yahoo.com> Message-ID: <1145610919.4448a2a722935@webmail.raincode.com> We (http://www.ertmssolutions.com/) provide an ethereal-like PROFIBUS network analyzer (http://www.ertmssolutions.com/sniffer.html) for ERTMS protocol stack used in european high-speed trains. IronPython enabled us to quickly provide a python scripting interface to our application, so that customers can write their own custom filtering/processing extensions. The product is in use today by several customers. Stanislas Pinte. -- ----------------------------------------------------------------- Stanislas Pinte e-mail: stan at ertmssolutions.com ERTMS Solutions http://www.ertmssolutions.com Rue de l'Autonomie, 1 Tel: + 322 - 522.06.63 1070 Bruxelles Fax: + 322 - 522.09.30 ----------------------------------------------------------------- Skype (http://www.skype.com) id: stanpinte ----------------------------------------------------------------- Selon ?? ?? : > in python's web site, > we can see a Success Stories link (http://www.python.org/about/success/), > I wonder who is using ironpython in their project. > > --------------------------------- > ????1G?????????????????????? > ????????-?????????????????? From michael.foord at resolversystems.com Fri Apr 21 10:35:40 2006 From: michael.foord at resolversystems.com (Michael Foord) Date: Fri, 21 Apr 2006 09:35:40 +0100 Subject: [IronPython] who is using ironpython in projects ? In-Reply-To: <20060421071523.68283.qmail@web15804.mail.cnb.yahoo.com> References: <20060421071523.68283.qmail@web15804.mail.cnb.yahoo.com> Message-ID: <4448995C.8060001@resolversystems.com> ? ? wrote: > in python's web site, > we can see a Success Stories link (http://www.python.org/about/success/), > I wonder who is using ironpython in their project. ResolverSystems are currently (and happily) developing a new project with IronPython - however the IronPython homepage ( http://www.ironpython.com/ ) is *seriously* outdated and misleading, so *any* improvement (even a redirect) would be a good thing... Michael Foord > ------------------------------------------------------------------------ > ??1G??????????? > ????-????????? > ------------------------------------------------------------------------ > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From michael.foord at resolversystems.com Fri Apr 21 11:09:43 2006 From: michael.foord at resolversystems.com (Michael Foord) Date: Fri, 21 Apr 2006 10:09:43 +0100 Subject: [IronPython] Problems with imp and marshall Message-ID: <4448A157.4020904@resolversystems.com> Hello all, I've encountered problems with the marshal and imp modules (tested with Beta 5 not Beta 6). marshal.loads can't unmarshal code objects preserved in Python 2.4 bytecode files. marshal.dumps can't marshal code objects. imp.new_module returns None. Any idea if/when these will be fixed ? Also, did I hear rumours of an ntpath module ? All the best, Michael Foord http://www.ResolverSystems.com From dinov at exchange.microsoft.com Fri Apr 21 16:57:16 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 21 Apr 2006 07:57:16 -0700 Subject: [IronPython] who is using ironpython in projects ? In-Reply-To: <4448995C.8060001@resolversystems.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E028DC77C@df-foxhound-msg.exchange.corp.microsoft.com> Yes, we're aware of this - Current plan is to update the webpage before 1.0 final. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Friday, April 21, 2006 1:36 AM To: Discussion of IronPython Subject: Re: [IronPython] who is using ironpython in projects ? ? ? wrote: > in python's web site, > we can see a Success Stories link (http://www.python.org/about/success/), > I wonder who is using ironpython in their project. ResolverSystems are currently (and happily) developing a new project with IronPython - however the IronPython homepage ( http://www.ironpython.com/ ) is *seriously* outdated and misleading, so *any* improvement (even a redirect) would be a good thing... Michael Foord > ------------------------------------------------------------------------ > ??1G??????????? > ????-????????? > ------------------------------------------------------------------------ > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From dinov at exchange.microsoft.com Fri Apr 21 16:59:48 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 21 Apr 2006 07:59:48 -0700 Subject: [IronPython] Unable to view IronPython Tutorial image In-Reply-To: <5b0248170604210104o39f68848wa69bc683fb330c8c@mail.gmail.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E028DC781@df-foxhound-msg.exchange.corp.microsoft.com> Thanks for the report Seo, we'll get this one fixed for the next release. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sanghyeon Seo Sent: Friday, April 21, 2006 1:05 AM To: Discussion of IronPython Subject: [IronPython] Unable to view IronPython Tutorial image While reading Tutorial.htm, dialog2.jpg didn't load, because file was named dialog2.JPG (uppercase) in ZIP file. This causes a problem in case-sensitive file systems. Seo Sanghyeon _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Fri Apr 21 17:03:03 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 21 Apr 2006 08:03:03 -0700 Subject: [IronPython] RE_Match.string In-Reply-To: <5b0248170604210026o35e383d4uc5c774c97af6e358@mail.gmail.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E028DC788@df-foxhound-msg.exchange.corp.microsoft.com> Again, thanks for the bug report (and thanks for keeping them coming!). We should get this one fixed for beta 7. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sanghyeon Seo Sent: Friday, April 21, 2006 12:27 AM To: Discussion of IronPython Subject: [IronPython] RE_Match.string # test.py import re print re.search('b', 'abc').string # CPython abc # IronPython b Seo Sanghyeon _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From giles.thomas at resolversystems.com Fri Apr 21 17:07:44 2006 From: giles.thomas at resolversystems.com (Giles Thomas) Date: Fri, 21 Apr 2006 16:07:44 +0100 Subject: [IronPython] who is using ironpython in projects ? In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E028DC77C@df-foxhound-msg.exchange.corp.microsoft.com> References: <4039D552ADAB094BB1EA670F3E96214E028DC77C@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <4448F540.20206@resolversystems.com> Hi Dino, Is there any chance you could add a simple link to the up-to-date site before then? It leads to some confusion when, say, we tell someone interested in joining our team that one of the technologies we use is IronPython, and they then "discover" from the first result from a Google search that it hasn't been updated since July 2004... Regards, Giles -- Giles Thomas Resolver Systems giles.thomas at resolversystems.com Dino Viehland wrote: >Yes, we're aware of this - Current plan is to update the webpage before 1.0 final. > >Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) > >-----Original Message----- >From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord >Sent: Friday, April 21, 2006 1:36 AM >To: Discussion of IronPython >Subject: Re: [IronPython] who is using ironpython in projects ? > >? ? wrote: > > >>in python's web site, >>we can see a Success Stories link (http://www.python.org/about/success/), >>I wonder who is using ironpython in their project. >> >> >ResolverSystems are currently (and happily) developing a new project >with IronPython - however the IronPython homepage ( >http://www.ironpython.com/ ) is *seriously* outdated and misleading, so >*any* improvement (even a redirect) would be a good thing... > >Michael Foord > > > >>------------------------------------------------------------------------ >>??1G??????????? >>????-????????? >>------------------------------------------------------------------------ >> >>_______________________________________________ >>users mailing list >>users at lists.ironpython.com >>http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> >> > > > >------------------------------------------------------------------------ > >_______________________________________________ >users mailing list >users at lists.ironpython.com >http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > From dinov at exchange.microsoft.com Fri Apr 21 17:08:56 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 21 Apr 2006 08:08:56 -0700 Subject: [IronPython] time.strftime have different output in ironpython and python In-Reply-To: <20060421071304.67437.qmail@web15804.mail.cnb.yahoo.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E028DC797@df-foxhound-msg.exchange.corp.microsoft.com> Thanks for the bug report. It?s definitely broken although it?s not yet clear why (we translate this into the appropriate .NET string formatting code which should work). I?ll open a bug and it seems like we should be able to get this one fixed for beta 7. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of ? ? Sent: Friday, April 21, 2006 12:13 AM To: users at lists.ironpython.com Subject: [IronPython] time.strftime have different output in ironpython and python IronPython 1.0.60420 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import time >>> time.strftime("%x %X", time.localtime() ) u'21 \u4e0b' >>> ActivePython 2.3.5 Build 236 (ActiveState Corp.) based on Python 2.3.5 (#62, Feb 9 2005, 16:17:08) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import time >>> time.strftime("%x %X", time.localtime() ) '04/21/06 14:30:46' >>> ________________________________ ??1G??????????? -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Fri Apr 21 17:12:12 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 21 Apr 2006 08:12:12 -0700 Subject: [IronPython] who is using ironpython in projects ? In-Reply-To: <4448F540.20206@resolversystems.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E028DC79D@df-foxhound-msg.exchange.corp.microsoft.com> I'll point this out to the point who are driving this and see if we can get it done sooner rather than later, but unfortunately I can't promise anything. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Giles Thomas Sent: Friday, April 21, 2006 8:08 AM To: Discussion of IronPython Subject: Re: [IronPython] who is using ironpython in projects ? Hi Dino, Is there any chance you could add a simple link to the up-to-date site before then? It leads to some confusion when, say, we tell someone interested in joining our team that one of the technologies we use is IronPython, and they then "discover" from the first result from a Google search that it hasn't been updated since July 2004... Regards, Giles -- Giles Thomas Resolver Systems giles.thomas at resolversystems.com Dino Viehland wrote: >Yes, we're aware of this - Current plan is to update the webpage before 1.0 final. > >Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) > >-----Original Message----- >From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord >Sent: Friday, April 21, 2006 1:36 AM >To: Discussion of IronPython >Subject: Re: [IronPython] who is using ironpython in projects ? > >? ? wrote: > > >>in python's web site, >>we can see a Success Stories link (http://www.python.org/about/success/), >>I wonder who is using ironpython in their project. >> >> >ResolverSystems are currently (and happily) developing a new project >with IronPython - however the IronPython homepage ( >http://www.ironpython.com/ ) is *seriously* outdated and misleading, so >*any* improvement (even a redirect) would be a good thing... > >Michael Foord > > > >>------------------------------------------------------------------------ >>??1G??????????? >>????-????????? >>------------------------------------------------------------------------ >> >>_______________________________________________ >>users mailing list >>users at lists.ironpython.com >>http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> >> > > > >------------------------------------------------------------------------ > >_______________________________________________ >users mailing list >users at lists.ironpython.com >http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > From KBjorke at nvidia.com Fri Apr 21 19:42:16 2006 From: KBjorke at nvidia.com (Kevin Bjorke) Date: Fri, 21 Apr 2006 10:42:16 -0700 Subject: [IronPython] who is using ironpython in projects ? Message-ID: <590FCAE72E27D54CA1EADE7293BB444F0442295E@hqemmail04.nvidia.com> We are: http://developer.nvidia.com/object/fx-composer2-pipeline-gdc-2006.html ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of ? ? Sent: Friday, April 21, 2006 12:15 AM To: users at lists.ironpython.com Subject: [IronPython] who is using ironpython in projects ? in python's web site, we can see a Success Stories link (http://www.python.org/about/success/), I wonder who is using ironpython in their project. ________________________________ ??1G??????????? ????-????????? ----------------------------------------------------------------------------------- This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. ----------------------------------------------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From kristof.wagemans at gmail.com Fri Apr 21 22:23:45 2006 From: kristof.wagemans at gmail.com (Kristof Wagemans) Date: Fri, 21 Apr 2006 22:23:45 +0200 Subject: [IronPython] IronMath Message-ID: <000601c66581$7e3002a0$0f01a8c0@notebook> Why is there a separate IronMath project that only contains two files? Having one project and one dll is easier to manage for integration reasons and for redistribution. Since IronPython cannot work without IronMath why don't you merge them? -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Fri Apr 21 22:28:39 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 21 Apr 2006 13:28:39 -0700 Subject: [IronPython] IronMath In-Reply-To: <000601c66581$7e3002a0$0f01a8c0@notebook> Message-ID: <4039D552ADAB094BB1EA670F3E96214E028DCB26@df-foxhound-msg.exchange.corp.microsoft.com> We keep them separated to try and avoid Python-isms in the IronMath library. We'd really like to see the day when all languages have some shared concept of a BigInteger and Complex, unfortunately these types are not available in the BCL. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Kristof Wagemans Sent: Friday, April 21, 2006 1:24 PM To: users at lists.ironpython.com Subject: [IronPython] IronMath Why is there a separate IronMath project that only contains two files? Having one project and one dll is easier to manage for integration reasons and for redistribution. Since IronPython cannot work without IronMath why don't you merge them? -------------- next part -------------- An HTML attachment was scrubbed... URL: From viola at microsoft.com Sat Apr 22 09:19:27 2006 From: viola at microsoft.com (Paul Viola) Date: Sat, 22 Apr 2006 00:19:27 -0700 Subject: [IronPython] Strangeness in list comprehensions in beta 6 In-Reply-To: Message-ID: <10073B83C89F804AABF10BD5F77AF081B36D69@RED-MSG-70.redmond.corp.microsoft.com> Folks, I defined a C++/CLI IEnumerator > class (a sparse matrix class). When I use it in a comprehension(see below) IP seems to "automatically" return only the value part of the KeyValuePair. IronPython 1.0.2302 (Beta) on .NET 2.0.50727.40 Copyright (c) Microsoft Corporation. All rights reserved. >>> import ShoNS >>> sss = ShoNS.Array.SparseArray(1000, 1000, 1000) >>> sss[100, 10] = 1 >>> sss[2, 10] = 2 ## Test the IEnumerator directly ## >>> eee = sss.ColumnElements(10) >>> eee.MoveNext() True >>> eee.Current [100, 1] ## Type is right!! ## >>> type(eee.Current) ## Strange that this does not work ### >>> [s for s in sss.ColumnElements(10)] [1.0, 2.0] ## Even worse, this is a bug!!! ## >>> for s in sss.ColumnElements(10): print s.Key, "->", s.Value ... Traceback (most recent call last): File , line 0, in input##203 AttributeError: 'float' object has no attribute 'Key' >>> Thanks, Paul Viola Senior Researcher Microsoft Research -------------- next part -------------- An HTML attachment was scrubbed... URL: From sanxiyn at gmail.com Sun Apr 23 02:31:27 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Sun, 23 Apr 2006 09:31:27 +0900 Subject: [IronPython] DB-API for IronPython update Message-ID: <5b0248170604221731p2b9f53e1o17a32d645bf41e53@mail.gmail.com> I updated DB-API module for IronPython a bit: http://sparcs.kaist.ac.kr/~tinuviel/fepy/lib/ The example was updated too: http://sparcs.kaist.ac.kr/~tinuviel/fepy/example/database_access.py Changes since the last update are: * Implement Cursor.description using GetSchemaTable() * Make it possible to choose which DB modules to test in the example Enjoy! Seo Sanghyeon From lattam at mac.com Sun Apr 23 19:43:51 2006 From: lattam at mac.com (Michael Latta) Date: Sun, 23 Apr 2006 10:43:51 -0700 Subject: [IronPython] Basic performance and feature questions Message-ID: <001501c666fd$7c927590$020fc80a@M4> I have some questions about IronPython regarding some of the more dynamic features: 1) What is the relative performance cost of using methods added to an object rather than defined in a class? 2) Is there a way to clone an object that includes all the methods added to it? In other words how well would IronPython support a Self type programming model where instances were the focus rather than classes? Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: From smppms2002 at yahoo.com.cn Mon Apr 24 09:42:51 2006 From: smppms2002 at yahoo.com.cn (smppms2002) Date: Mon, 24 Apr 2006 15:42:51 +0800 (CST) Subject: [IronPython] invoke CreateApplicationHost in ironpython failed? Message-ID: <20060424074251.47516.qmail@web15802.mail.cnb.yahoo.com> invoke CreateApplicationHost in ironpython failed? I want to implement a mini asp.net web server in ironpython, but I am a .NET newbie, so I google some article about ASMX in msdn (https://msdn.microsoft.com/msdnmag/issues/04/12/ServiceStation/), then write a simple demo, but some errors happen. below is the error message and source . D:\IronPython\httpd>IronPythonConsole IronPython 1.0.60420 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> ^Z D:\IronPython\httpd>IronPythonConsole http_test2.py Traceback (most recent call last): File D:\IronPython\httpd\http_test2.py, line 57, in Initialize File D:\IronPython\httpd\http_test2.py, line 34, in test File , line 0, in CreateApplicationHost##12 File System.Web, line unknown, in CreateApplicationHost File System.Web, line unknown, in CreateInstanceInNewWorkerAppDomain File System.Web, line unknown, in CreateInstance IOError: Could not load file or assembly 'snippets1, Version=0.0.0.0, Culture=ne utral, PublicKeyToken=null' or one of its dependencies. import sys import nt import clr clr.AddReference("System.Web") from System import * from System.Web import * from System.Web.Hosting import * from System.Diagnostics import * from System.Text import * from System.Net import * from System.Net.Sockets import * from System.Threading import * class aspxHost(MarshalByRefObject): def ProcessRequest(self, webpage, query, tw): swr = SimpleWorkerRequest( webpage, query, tw ) HttpRuntime.ProcessRequest(swr) def test(): _tmphost = aspxHost() host = ApplicationHost.CreateApplicationHost( _tmphost.GetType(), "/", nt.getcwd() ) listener = HttpListener() listener.Prefixes.Add("http://localhost:80/") listener.Prefixes.Add("http://127.0.0.1:80/") listener.Start() print "Listening for requests on http://localhost:80/" while True: ctx = listener.GetContext() page = ctx.Request.Url.LocalPath.Replace("/", "") query = ctx.Request.Url.Query.Replace("?", "") print "page is [%s] query is [%s]" %( page, query ) sw = StreamWriter(ctx.Response.OutputStream) msh.ProcessRequest(page, query, sw) sw.Flush() ctx.Response.Close() if __name__ == "__main__": test() thanks a lot. ___________________________________________________________ ?????????????????????????? http://cn.photos.yahoo.com ___________________________________________________________ ????????????? From lupus at ximian.com Mon Apr 24 11:52:39 2006 From: lupus at ximian.com (Paolo Molaro) Date: Mon, 24 Apr 2006 11:52:39 +0200 Subject: [IronPython] [Mono-dev] IronPython Performance In-Reply-To: <20060421230154.1586.qmail@web81205.mail.mud.yahoo.com> References: <20060421230154.1586.qmail@web81205.mail.mud.yahoo.com> Message-ID: <20060424095239.GQ3151@debian.org> [I continued your large cross-post, even if I'm not subscribed to python-dev: hopefully the moderators will approve the post if needed.] On 04/21/06 Brent Fulgham wrote: > A while ago (nearly two years) an interesting paper was published by Jim Hugunin > (http://www.python.org/pycon/dc2004/papers/9/) crowing about the significant > speed advantage observed in this interpreter running on top of Microsoft's .NET > VM stack. I remember being surprised by these results, as Python has always > seemed fairly fast for an interpreted language. > > I've been working on the Programming Language Shootout for a few years now, and > after growing tired of the repeated requests to include scores for IronPython I > finally added the implementation this week. > > Comparison of IronPython (1.0 Beta 5) to Python 2.4.3 [1] and IronPython (1.0 Beta 1) > to Python 2.4.2 [2] do not match the results reported in the 2004 paper. In fact, > IronPython is consistenly 3 to 4 times slower (in some cases worse than that), and > seemed to suffer from recursion/stack limitations. You're comparing different benchmarks, so it's not a surprise that you get different numbers. I only tried two benchmarks from the paper, pystone and the globals one (attached) and the results are largely equivalent to the ones from the paper: time mono IronPython-1.0-Beta6/IronPythonConsole.exe -O python-globals-bench2.py real 0m0.861s user 0m0.815s sys 0m0.043s (Note the above includes the startup time that I guess was not considered in the paper and is 0.620 seconds running test(1): just increasing the number of iterations will make the difference converge at about 10x faster mono vs python2.4). time python2.4 -O python-globals-bench2.py real 0m2.239s user 0m2.202s sys 0m0.025s python2.4 -O /usr/lib/python2.4/test/pystone.py Pystone(1.1) time for 50000 passes = 1.4 This machine benchmarks at 35714.3 pystones/second mono IronPython-1.0-Beta6/IronPythonConsole.exe -O /usr/lib/python2.4/test/pystone.py Pystone(1.1) time for 50000 passes = 0.989288 This machine benchmarks at 50541.4 pystones/second So IronPython is 40+% faster than CPython, like in the paper. The mono version I used is roughtly 1.1.14. As for the recursion limitations: what are they? I took the recursive benchmark from the shootout page and both CPython and IronPython need the call to setrecursionlimit (actually cpython needed it earlier for me, anyway). This might be a difference between IronPython beta 5 and the beta6 I'm using, though. It is also interesting because on my system running the attached python-ack.py with 8 as argument, mono/IronPython is 10% faster than CPython, while the shootout page reports CPython 2.4 50% faster. Feel free to investigate if this is because of improvements in mono or IronPython:) > I am aware of the following issues that might affect the results: > 1) Mono vs. Microsoft's CLR. This can certainly be a factor: some things in the MS runtime run faster and some slower than in the Mono runtime, so it depends which features are exercised the most in a particular benchmark. It is very likely that in most benchmarks the MS runtime will score better. > 2) Python 2.1 vs. Python 2.4 The python folks will have more details, but python2.4 seems to be faster than 2.1 and 2.3 in several areas. > 3) Changes in IronPython over the last two years. For some time the IronPython folks have focused on features and correctness issues, so I guess they'll start caring about performance in the future. It is also to note that IronPython now uses generics which have yet to see optimizations work in the mono runtime and libraries (they are a 2.0 feature). > I thought these findings might be interesting to some of the Python, IronPython, > and Mono developers. Let the flames begin! ;-) Why flames? Hard numbers are just that: useful information. It's just your conclusions that might be incorrect;-) I think the summary to take away is: *) Sometimes IronPython on mono is faster than CPython *) Often CPython is faster than IronPython on mono *) IronPython and mono are improving quickly. Thanks for the numbers: it would be nice if someone with time in his hands could rerun the benchmarks with ironpython beta6, mono from svn (or at least mono 1.1.14/1.1.15) and also with the MS runtime on windows. Better if this includes running pystone to relate to improvements in the published paper and the piethon benchmarks (on the MS runtime, in mono we need to implement some things that newer ironpythons use). In the meantime here are the piethon results running with IronPython 0.6 with a current mono. Mono results: b0 = 2.49623870849609 -- [2.59130096435547, 2.40117645263672] b1 = 0.473392486572266 -- [0.496170043945312, 0.450614929199219] b2 = 0.453083038330078 -- [0.543968200683594, 0.362197875976562] b3 = 0.967914581298828 -- [0.995307922363281, 0.940521240234375] b4 = 1.11585998535156 -- [1.23159027099609, 1.00012969970703] b5 = 3.56014633178711 -- [3.70928192138672, 3.4110107421875] b6 = 1.43364334106445 -- [1.42024230957031, 1.44704437255859] all done in 21.01 sec Python 2.4 results: b0 = 2.185000 -- [2.1800000000000002, 2.1900000000000004] b1 = 0.915000 -- [0.93999999999999995, 0.88999999999999879] b2 = 0.395000 -- [0.39999999999999991, 0.39000000000000057] b3 = 1.015000 -- [1.02, 1.0099999999999998] b4 = 0.585000 -- [0.58999999999999986, 0.58000000000000007] b5 = 0.995000 -- [0.99000000000000021, 1.0] b6 = 1.410000 -- [1.4199999999999999, 1.4000000000000004] all done in 15.00 sec Python 2.3 results: b0 = 2.270000 -- [2.2800000000000002, 2.2600000000000016] b1 = 0.955000 -- [0.98999999999999977, 0.91999999999999993] b2 = 0.395000 -- [0.39000000000000012, 0.39999999999999858] b3 = 1.230000 -- [1.2300000000000004, 1.2300000000000004] b4 = 0.805000 -- [0.80999999999999961, 0.80000000000000071] b5 = 1.145000 -- [1.1500000000000004, 1.1399999999999988] b6 = 1.500000 -- [1.5099999999999989, 1.4900000000000002] all done in 16.60 sec Since Guido designed it to excercise the tricky corners of the python implementation this could be a better general evaluation of the speed of a python runtime. Note that in the oscon paper, mono was reported to be 23 time slower than CPython (but 2 times slower excluding b5 where we had a really unoptimized codepath). Current mono is 27% slower than CPython 2.3 and 40% slower than CPython 2.4. So while the CPython performance increased, mono's rate of improvement is significantly faster. While having mono/IronPython be faster than CPython in more benchmarks would be nice (and I guess we could run a few profile runs if there is interest to see if some quick specific improvement could be done), it is not really necessary. Having mono run python code 1-2 times slower than CPython is pretty good. People interested in raw performance could just write the code in C#, gluelessly use it from python code and get the 1-2 orders of magnitude improvements visible also in the shootout comparison of C# vs python. Thanks. lupus -- ----------------------------------------------------------------- lupus at debian.org debian/rules lupus at ximian.com Monkeys do it better From dinov at exchange.microsoft.com Mon Apr 24 17:42:39 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 24 Apr 2006 08:42:39 -0700 Subject: [IronPython] Basic performance and feature questions In-Reply-To: <001501c666fd$7c927590$020fc80a@M4> Message-ID: <4039D552ADAB094BB1EA670F3E96214E0297096F@df-foxhound-msg.exchange.corp.microsoft.com> The only cost here is the cost of looking up the method. Once we've got the method dispatch will be the same whether it's defined in the class or the instance. (There may be some improvements we can make to make methods in the class faster in the future, but this is true today). In the case of old-style classes, it makes no difference (we'll lookup in the instance first, so presumably it could be even a little faster than having it on the class). In the case of new-style classes, which can live w/o an instance dictionary, the cost will be paid when you add the first method. It's the same cost as if you had added some arbitrary field though, and that cost will be paid on every method call (as we'll be forced to check if the instance has overridden any methods). The cost here is that you're forcing an additional dictionary lookup on invocation. But we always check the instance first, so for you this means your path becomes fast, and the normal path becomes slow. There's the copy module but we don't fully support __reduce__ everywhere you'd need it. You can always copy the items in the dict, w/ any filter you want: class foo(object): def __init__(self): self.bar = bar def bar(self, xyz): pass a = foo() a.bar = bar b = foo() import operator for x in a.__dict__.keys(): if operator.isCallable(a.__dict__[x]) and not b.__dict__.has_key(x): b.__dict__[x] = a.__dict__[x] Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Latta Sent: Sunday, April 23, 2006 10:44 AM To: 'Discussion of IronPython' Subject: [IronPython] Basic performance and feature questions I have some questions about IronPython regarding some of the more dynamic features: 1) What is the relative performance cost of using methods added to an object rather than defined in a class? 2) Is there a way to clone an object that includes all the methods added to it? In other words how well would IronPython support a Self type programming model where instances were the focus rather than classes? Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Mon Apr 24 17:47:19 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 24 Apr 2006 08:47:19 -0700 Subject: [IronPython] [Mono-dev] IronPython Performance In-Reply-To: <20060424095239.GQ3151@debian.org> Message-ID: <4039D552ADAB094BB1EA670F3E96214E02970979@df-foxhound-msg.exchange.corp.microsoft.com> On the recursion limits: Until beta 6 IronPython didn't have proper support for limiting recursion depth. There was some minor support there, but it wasn't right. In beta 6 we have full support for limiting recursion depth, but by default we allow infinite recursion. If the user explicitly sets the recursion limit then we'll go ahead and enforce it. But all the reasons you outline below are great explanations of the differences. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Paolo Molaro Sent: Monday, April 24, 2006 2:53 AM To: Brent Fulgham Cc: shootout-list at lists.alioth.debian.org; python-dev at python.org; users at lists.ironpython.com; mono-devel-list at lists.ximian.com Subject: Re: [IronPython] [Mono-dev] IronPython Performance [I continued your large cross-post, even if I'm not subscribed to python-dev: hopefully the moderators will approve the post if needed.] On 04/21/06 Brent Fulgham wrote: > A while ago (nearly two years) an interesting paper was published by Jim Hugunin > (http://www.python.org/pycon/dc2004/papers/9/) crowing about the significant > speed advantage observed in this interpreter running on top of Microsoft's .NET > VM stack. I remember being surprised by these results, as Python has always > seemed fairly fast for an interpreted language. > > I've been working on the Programming Language Shootout for a few years now, and > after growing tired of the repeated requests to include scores for IronPython I > finally added the implementation this week. > > Comparison of IronPython (1.0 Beta 5) to Python 2.4.3 [1] and IronPython (1.0 Beta 1) > to Python 2.4.2 [2] do not match the results reported in the 2004 paper. In fact, > IronPython is consistenly 3 to 4 times slower (in some cases worse than that), and > seemed to suffer from recursion/stack limitations. You're comparing different benchmarks, so it's not a surprise that you get different numbers. I only tried two benchmarks from the paper, pystone and the globals one (attached) and the results are largely equivalent to the ones from the paper: time mono IronPython-1.0-Beta6/IronPythonConsole.exe -O python-globals-bench2.py real 0m0.861s user 0m0.815s sys 0m0.043s (Note the above includes the startup time that I guess was not considered in the paper and is 0.620 seconds running test(1): just increasing the number of iterations will make the difference converge at about 10x faster mono vs python2.4). time python2.4 -O python-globals-bench2.py real 0m2.239s user 0m2.202s sys 0m0.025s python2.4 -O /usr/lib/python2.4/test/pystone.py Pystone(1.1) time for 50000 passes = 1.4 This machine benchmarks at 35714.3 pystones/second mono IronPython-1.0-Beta6/IronPythonConsole.exe -O /usr/lib/python2.4/test/pystone.py Pystone(1.1) time for 50000 passes = 0.989288 This machine benchmarks at 50541.4 pystones/second So IronPython is 40+% faster than CPython, like in the paper. The mono version I used is roughtly 1.1.14. As for the recursion limitations: what are they? I took the recursive benchmark from the shootout page and both CPython and IronPython need the call to setrecursionlimit (actually cpython needed it earlier for me, anyway). This might be a difference between IronPython beta 5 and the beta6 I'm using, though. It is also interesting because on my system running the attached python-ack.py with 8 as argument, mono/IronPython is 10% faster than CPython, while the shootout page reports CPython 2.4 50% faster. Feel free to investigate if this is because of improvements in mono or IronPython:) > I am aware of the following issues that might affect the results: > 1) Mono vs. Microsoft's CLR. This can certainly be a factor: some things in the MS runtime run faster and some slower than in the Mono runtime, so it depends which features are exercised the most in a particular benchmark. It is very likely that in most benchmarks the MS runtime will score better. > 2) Python 2.1 vs. Python 2.4 The python folks will have more details, but python2.4 seems to be faster than 2.1 and 2.3 in several areas. > 3) Changes in IronPython over the last two years. For some time the IronPython folks have focused on features and correctness issues, so I guess they'll start caring about performance in the future. It is also to note that IronPython now uses generics which have yet to see optimizations work in the mono runtime and libraries (they are a 2.0 feature). > I thought these findings might be interesting to some of the Python, IronPython, > and Mono developers. Let the flames begin! ;-) Why flames? Hard numbers are just that: useful information. It's just your conclusions that might be incorrect;-) I think the summary to take away is: *) Sometimes IronPython on mono is faster than CPython *) Often CPython is faster than IronPython on mono *) IronPython and mono are improving quickly. Thanks for the numbers: it would be nice if someone with time in his hands could rerun the benchmarks with ironpython beta6, mono from svn (or at least mono 1.1.14/1.1.15) and also with the MS runtime on windows. Better if this includes running pystone to relate to improvements in the published paper and the piethon benchmarks (on the MS runtime, in mono we need to implement some things that newer ironpythons use). In the meantime here are the piethon results running with IronPython 0.6 with a current mono. Mono results: b0 = 2.49623870849609 -- [2.59130096435547, 2.40117645263672] b1 = 0.473392486572266 -- [0.496170043945312, 0.450614929199219] b2 = 0.453083038330078 -- [0.543968200683594, 0.362197875976562] b3 = 0.967914581298828 -- [0.995307922363281, 0.940521240234375] b4 = 1.11585998535156 -- [1.23159027099609, 1.00012969970703] b5 = 3.56014633178711 -- [3.70928192138672, 3.4110107421875] b6 = 1.43364334106445 -- [1.42024230957031, 1.44704437255859] all done in 21.01 sec Python 2.4 results: b0 = 2.185000 -- [2.1800000000000002, 2.1900000000000004] b1 = 0.915000 -- [0.93999999999999995, 0.88999999999999879] b2 = 0.395000 -- [0.39999999999999991, 0.39000000000000057] b3 = 1.015000 -- [1.02, 1.0099999999999998] b4 = 0.585000 -- [0.58999999999999986, 0.58000000000000007] b5 = 0.995000 -- [0.99000000000000021, 1.0] b6 = 1.410000 -- [1.4199999999999999, 1.4000000000000004] all done in 15.00 sec Python 2.3 results: b0 = 2.270000 -- [2.2800000000000002, 2.2600000000000016] b1 = 0.955000 -- [0.98999999999999977, 0.91999999999999993] b2 = 0.395000 -- [0.39000000000000012, 0.39999999999999858] b3 = 1.230000 -- [1.2300000000000004, 1.2300000000000004] b4 = 0.805000 -- [0.80999999999999961, 0.80000000000000071] b5 = 1.145000 -- [1.1500000000000004, 1.1399999999999988] b6 = 1.500000 -- [1.5099999999999989, 1.4900000000000002] all done in 16.60 sec Since Guido designed it to excercise the tricky corners of the python implementation this could be a better general evaluation of the speed of a python runtime. Note that in the oscon paper, mono was reported to be 23 time slower than CPython (but 2 times slower excluding b5 where we had a really unoptimized codepath). Current mono is 27% slower than CPython 2.3 and 40% slower than CPython 2.4. So while the CPython performance increased, mono's rate of improvement is significantly faster. While having mono/IronPython be faster than CPython in more benchmarks would be nice (and I guess we could run a few profile runs if there is interest to see if some quick specific improvement could be done), it is not really necessary. Having mono run python code 1-2 times slower than CPython is pretty good. People interested in raw performance could just write the code in C#, gluelessly use it from python code and get the 1-2 orders of magnitude improvements visible also in the shootout comparison of C# vs python. Thanks. lupus -- ----------------------------------------------------------------- lupus at debian.org debian/rules lupus at ximian.com Monkeys do it better _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Mon Apr 24 18:07:06 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 24 Apr 2006 09:07:06 -0700 Subject: [IronPython] invoke CreateApplicationHost in ironpython failed? In-Reply-To: <20060424074251.47516.qmail@web15802.mail.cnb.yahoo.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E0297099B@df-foxhound-msg.exchange.corp.microsoft.com> I suspect you're hitting cross-app domain issues. A quick search shows that you need to have your assemblies in a "bin" directory for ASP.NET to find them, but IronPython is going to generate its snippets.dll somewhere else (usually the current working directory). One thing you could try, not sure if it'll help, but if you layout your directory like: D:\IronPython\httpd\bin\ IronPythonConsole.exe IronPython.dll ... Then run from httpd: D:\IronPython\httpd> bin\IronPythonConsole.exe Then maybe snippets will end up in bin. If that doesn't work you can try updating the path in OutputGenerator.CreateNewSnippetAssembly in IronPython\Compiler to point to a bin subdirectory. If that works we could add a command line option to specify where this should get generated. If none of those works it might help for you to re-run w/ the -X:ExceptionDetail command line option so we can see where from within .NET this is actually throwing. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of smppms2002 Sent: Monday, April 24, 2006 12:43 AM To: users at lists.ironpython.com Subject: [IronPython] invoke CreateApplicationHost in ironpython failed? invoke CreateApplicationHost in ironpython failed? I want to implement a mini asp.net web server in ironpython, but I am a .NET newbie, so I google some article about ASMX in msdn (https://msdn.microsoft.com/msdnmag/issues/04/12/ServiceStation/), then write a simple demo, but some errors happen. below is the error message and source . D:\IronPython\httpd>IronPythonConsole IronPython 1.0.60420 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> ^Z D:\IronPython\httpd>IronPythonConsole http_test2.py Traceback (most recent call last): File D:\IronPython\httpd\http_test2.py, line 57, in Initialize File D:\IronPython\httpd\http_test2.py, line 34, in test File , line 0, in CreateApplicationHost##12 File System.Web, line unknown, in CreateApplicationHost File System.Web, line unknown, in CreateInstanceInNewWorkerAppDomain File System.Web, line unknown, in CreateInstance IOError: Could not load file or assembly 'snippets1, Version=0.0.0.0, Culture=ne utral, PublicKeyToken=null' or one of its dependencies. import sys import nt import clr clr.AddReference("System.Web") from System import * from System.Web import * from System.Web.Hosting import * from System.Diagnostics import * from System.Text import * from System.Net import * from System.Net.Sockets import * from System.Threading import * class aspxHost(MarshalByRefObject): def ProcessRequest(self, webpage, query, tw): swr = SimpleWorkerRequest( webpage, query, tw ) HttpRuntime.ProcessRequest(swr) def test(): _tmphost = aspxHost() host = ApplicationHost.CreateApplicationHost( _tmphost.GetType(), "/", nt.getcwd() ) listener = HttpListener() listener.Prefixes.Add("http://localhost:80/") listener.Prefixes.Add("http://127.0.0.1:80/") listener.Start() print "Listening for requests on http://localhost:80/" while True: ctx = listener.GetContext() page = ctx.Request.Url.LocalPath.Replace("/", "") query = ctx.Request.Url.Query.Replace("?", "") print "page is [%s] query is [%s]" %( page, query ) sw = StreamWriter(ctx.Response.OutputStream) msh.ProcessRequest(page, query, sw) sw.Flush() ctx.Response.Close() if __name__ == "__main__": test() thanks a lot. ___________________________________________________________ ?????????????????????????? http://cn.photos.yahoo.com ___________________________________________________________ ????????????? From nicholasinparis at gmail.com Mon Apr 24 20:14:50 2006 From: nicholasinparis at gmail.com (Nicholas) Date: Mon, 24 Apr 2006 20:14:50 +0200 Subject: [IronPython] os module and directory/file commands Message-ID: Im a newbie to IP and am struggling to find how to list directories etc as was done using 'os' in CPython? Also what about Globbing? Are there any good sources of info for IP, I have just about worn out the tutorial. Any info would be much appreciated. -------------- next part -------------- An HTML attachment was scrubbed... URL: From vincent at visualtrans.de Mon Apr 24 20:31:37 2006 From: vincent at visualtrans.de (Vincent Wehren) Date: Mon, 24 Apr 2006 19:31:37 +0100 Subject: [IronPython] os module and directory/file commands In-Reply-To: Message-ID: <001701c667cd$54bc21d0$0200a8c0@VINWEHVAIO> You can just add c:\\Python24\\Lib to sys.path and use 'glob' and 'os' or any other pure-python module as you normally would. -- Vincent Wehren _____ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicholas Sent: 24 April 2006 19:15 To: users at lists.ironpython.com Subject: [IronPython] os module and directory/file commands Im a newbie to IP and am struggling to find how to list directories etc as was done using 'os' in CPython? Also what about Globbing? Are there any good sources of info for IP, I have just about worn out the tutorial. Any info would be much appreciated. -------------- next part -------------- An HTML attachment was scrubbed... URL: From sanxiyn at gmail.com Wed Apr 26 04:51:16 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Wed, 26 Apr 2006 11:51:16 +0900 Subject: [IronPython] IronPython 1.0 Beta 6 on Mono Message-ID: <5b0248170604251951p5d03217amf33d577b68fb1f7f@mail.gmail.com> Yeah, a bit late this time, but the usual Mono report is surely coming. Just in case, I am using Mono revision 59840. This report updates following previous reports: * Mar 10: http://lists.ironpython.com/pipermail/users-ironpython.com/2006-March/001919.html * Mar 30: http://lists.ironpython.com/pipermail/users-ironpython.com/2006-March/002062.html * Apr 3: http://lists.ironpython.com/pipermail/users-ironpython.com/2006-April/002080.html Runtime issues: * IsDaylightSavingTime: fixed in Mono revision 59432. * GetEncodings: still not fixed * SetEnvironmentVariable: fixed in Mono revision 58858. Compiler issues: * New-style classes failure (UserType.cs miscompilation): Mono bug #78031. fixed in Mono revision 59679. * Flow analysis crash (while compiling PythonEngine.cs): New in Beta 6. Mono bug #78156. fixed in Mono revision 59807. In summary, IronPython 1.0 Beta 6 should run and compile fine on SVN trunk. It seems that no released version will work for now, but check the SVN revision yourself against the information above. Seo Sanghyeon From Jean-Michel.Perraud at csiro.au Wed Apr 26 06:15:17 2006 From: Jean-Michel.Perraud at csiro.au (Jean-Michel.Perraud at csiro.au) Date: Wed, 26 Apr 2006 14:15:17 +1000 Subject: [IronPython] Using an IronPython console with a Winforms component supporting the interactive I/O Message-ID: <05872A8F41C74E478B332039E4150D5186BEDF@exactn1-cbr.nexus.csiro.au> Hi, I'd like to use IP in an interactive mode, but with the console being typically in an MDI child form that can be launched from the main application. After looking at a few possiblities I thought I should start from the SuperConsole or BasicConsole distributed with IP, and replace the System.Console with "some reusable code" with I/O streams redirected to/from a Winforms text-related control. Has anyone done that or something similar, or has links to relevant information? After 'googling' quite a bit, surprisingly I did not find much in the way of a Windows-based shell implementation doing the aforementioned. The closets (and niftiest) example I saw was the IronPython console sample in the latest preview Visual Studio SDK, but I'd really like it not to depend at all on the SDK API, so this makes it hard to reuse it without significant re-write. I don't deal often with console-based approaches, so bear with me if I missed something you think is obvious... Cheers, J-M From dinov at exchange.microsoft.com Thu Apr 27 05:20:56 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 26 Apr 2006 20:20:56 -0700 Subject: [IronPython] Using an IronPython console with a Winforms component supporting the interactive I/O In-Reply-To: <05872A8F41C74E478B332039E4150D5186BEDF@exactn1-cbr.nexus.csiro.au> References: <05872A8F41C74E478B332039E4150D5186BEDF@exactn1-cbr.nexus.csiro.au> Message-ID: <4039D552ADAB094BB1EA670F3E96214E235C7E@df-foxhound-msg.exchange.corp.microsoft.com> You're on the right track. You'll probably want to create a seperate thread for the PythonEngine to run on, and then whenever you get a write to your stream you can just do a Control.Invoke onto your UI thread to update the current output. I was playing around w/ this around the 0.9.4 time-frame and came up w/ the code below. This is a little old and I haven't looked at it in some time so there's no guarantees but maybe it'll help clarify things. It also doesn't sound like it's quite what you want (I was doing seperate windows for input/output), but it shouldn't be hard to get both going in the same text box. Good luck! class StreamToTextBox : Stream { RichTextBox _textBox; Color _targetColor; public StreamToTextBox(RichTextBox textBox, Color color) { _textBox = textBox; _targetColor = color; } public override void Write(byte[] buffer, int offset, int count) { string text = System.Text.Encoding.ASCII.GetString(buffer, offset, count); text.Replace("\r", "\r\n"); _textBox.BeginInvoke((System.Threading.ThreadStart)delegate() { _textBox.AppendText(text); _textBox.Select(_textBox.Text.Length-text.Length, text.Length); _textBox.SelectionColor = _targetColor; _textBox.Select(_textBox.Text.Length-1,0); _textBox.ScrollToCaret(); }); } // rest is uninteresting ... } class StreamReaderToTextBox : Stream { TextBox _textBox; Queue _pendingStrings; string _pendingStr; object _lockObj = new object(); public StreamReaderToTextBox(TextBox textBox) { _textBox = textBox; _textBox.KeyDown += new KeyEventHandler(_textBox_KeyDown); _pendingStrings = new Queue(); } /// /// Called on UI thread /// void _textBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Enter) { e.Handled = true; e.SuppressKeyPress = true; // read the text lock (_lockObj) { _pendingStrings.Enqueue(_textBox.Text); Monitor.Pulse(_lockObj); } _textBox.Text = null; } } /// /// Must be called on non-UI thread! /// public override int Read(byte[] buffer, int offset, int count) { string s; _textBox.BeginInvoke((ThreadStart)delegate() { _textBox.Visible = true; }); lock (_lockObj) { while (_pendingStrings.Count == 0 && _pendingStr == null) { Monitor.Wait(_lockObj); } s = (_pendingStr != null) ? _pendingStr : _pendingStrings.Dequeue(); _pendingStr = null; } int i = offset, curIndex = 0; for (; i < offset + count; i++, curIndex++) { if (curIndex == s.Length) { buffer[i] = (byte)'\n'; i++; _textBox.BeginInvoke((ThreadStart)delegate() { _textBox.Visible = false; }); return i - offset; } buffer[i] = (byte)s[curIndex]; } if (curIndex != s.Length) { _pendingStr = s.Substring(curIndex); } _textBox.Visible = false; return i - offset; } } ________________________________________ From: users-bounces at lists.ironpython.com On Behalf Of Jean-Michel.Perraud at csiro.au Sent: Tuesday, April 25, 2006 9:15 PM To: users at lists.ironpython.com Subject: [IronPython] Using an IronPython console with a Winforms component supporting the interactive I/O Hi, I'd like to use IP in an interactive mode, but with the console being typically in an MDI child form that can be launched from the main application. After looking at a few possiblities I thought I should start from the SuperConsole or BasicConsole distributed with IP, and replace the System.Console with "some reusable code" with I/O streams redirected to/from a Winforms text-related control. Has anyone done that or something similar, or has links to relevant information? After 'googling' quite a bit, surprisingly I did not find much in the way of a Windows-based shell implementation doing the aforementioned. The closets (and niftiest) example I saw was the IronPython console sample in the latest preview Visual Studio SDK, but I'd really like it not to depend at all on the SDK API, so this makes it hard to reuse it without significant re-write. I don't deal often with console-based approaches, so bear with me if I missed something you think is obvious... Cheers, J-M _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From sanxiyn at gmail.com Thu Apr 27 12:30:38 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Thu, 27 Apr 2006 19:30:38 +0900 Subject: [IronPython] un(shallow)copyable object Message-ID: <5b0248170604270330w793b53d0g7906a29132bbb759@mail.gmail.com> # test.py import copy class C(object): pass obj = C() copy.copy(obj) # IronPython Error: un(shallow)copyable object of type Seo Sanghyeon From Jean-Michel.Perraud at csiro.au Thu Apr 27 13:31:48 2006 From: Jean-Michel.Perraud at csiro.au (Jean-Michel.Perraud at csiro.au) Date: Thu, 27 Apr 2006 21:31:48 +1000 Subject: [IronPython] Generated IL is always using the standard input, output and error streams. Message-ID: <05872A8F41C74E478B332039E4150D5186BEE6@exactn1-cbr.nexus.csiro.au> Hi, First, thanks Dino and Szymon for the help I came across an issue: the only output displayed were stack traces. After a bit of investigation, I think the generated IL does not use the custom streams of the implementation of IConsole passed to the PythonEngine. The static property State of IP::Runtime::Ops is initialised with a SystemState setting its fields e.g. as: [PythonName("__stdout__")] public object __stdout__ = new PythonFile( Options.UnbufferedStdOutAndError ? Console.OpenStandardOutput(0) : Console.OpenStandardOutput(), Console.OutputEncoding, "", "w"); I think that the subsequent calls to the methods in the Ops class from the generated methods are using this State. Incidentally, the use of static methods/properties for Ops also effectively means that a PythonEngine should be used as a singleton if embedded in an application. I am well aware that trying not to rely on static method and singleton patterns often raises the code complexity a *lot* (been there, done that...). What is the current thinking on this topic? Cheers, J-M From dinov at exchange.microsoft.com Thu Apr 27 17:32:29 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 27 Apr 2006 08:32:29 -0700 Subject: [IronPython] un(shallow)copyable object In-Reply-To: <5b0248170604270330w793b53d0g7906a29132bbb759@mail.gmail.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E02A3CD82@df-foxhound-msg.exchange.corp.microsoft.com> Thanks for the bug report Seo! I've got this one filed and hopefully we can get to it for beta 7. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sanghyeon Seo Sent: Thursday, April 27, 2006 3:31 AM To: Discussion of IronPython Subject: [IronPython] un(shallow)copyable object # test.py import copy class C(object): pass obj = C() copy.copy(obj) # IronPython Error: un(shallow)copyable object of type Seo Sanghyeon _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Thu Apr 27 17:38:25 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 27 Apr 2006 08:38:25 -0700 Subject: [IronPython] Generated IL is always using the standard input, output and error streams. In-Reply-To: <05872A8F41C74E478B332039E4150D5186BEE6@exactn1-cbr.nexus.csiro.au> Message-ID: <4039D552ADAB094BB1EA670F3E96214E02A3CD88@df-foxhound-msg.exchange.corp.microsoft.com> Yep, you're correct - SystemState is currently a singleton for the entire process. We'll actually have this fixed in beta 7 where the system state is stored in a hidden spot in the module and we'll flow it as one module imports another. That'll result in a set of modules being independent and 'belonging' to a single system state and allows multiple engines to be hosted simultaneously. The engine does have a SetStderr / SetStdout / SetStdin API which should be used for this purpose. And the nice thing is as we rev to the multi-System state module this API will remain unchanged so you won't be broken in the future. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jean-Michel.Perraud at csiro.au Sent: Thursday, April 27, 2006 4:32 AM To: users at lists.ironpython.com Subject: [IronPython] Generated IL is always using the standard input, output and error streams. Hi, First, thanks Dino and Szymon for the help I came across an issue: the only output displayed were stack traces. After a bit of investigation, I think the generated IL does not use the custom streams of the implementation of IConsole passed to the PythonEngine. The static property State of IP::Runtime::Ops is initialised with a SystemState setting its fields e.g. as: [PythonName("__stdout__")] public object __stdout__ = new PythonFile( Options.UnbufferedStdOutAndError ? Console.OpenStandardOutput(0) : Console.OpenStandardOutput(), Console.OutputEncoding, "", "w"); I think that the subsequent calls to the methods in the Ops class from the generated methods are using this State. Incidentally, the use of static methods/properties for Ops also effectively means that a PythonEngine should be used as a singleton if embedded in an application. I am well aware that trying not to rely on static method and singleton patterns often raises the code complexity a *lot* (been there, done that...). What is the current thinking on this topic? Cheers, J-M _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From quantufinity at hotmail.com Thu Apr 27 23:06:05 2006 From: quantufinity at hotmail.com (Quantum Infinity) Date: Thu, 27 Apr 2006 16:06:05 -0500 Subject: [IronPython] Calling Win32 API in IronPython Message-ID: Hi All, This is my first post here and I hope this question was not asked before. Anyway, is there any way to call a Win32 API in IronPython? I was trying to search Google along the lines of DllImport and DLLImportAttribute but I could not find and working example. I also tried to use the samples from Boo but I couldn't make it to work in IronPython. In CPython, i can use CTypes and call Win32 API but I just am really lost with IronPython. Regards, Quantufinity _________________________________________________________________ Don?t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/ From dinov at exchange.microsoft.com Fri Apr 28 00:34:17 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 27 Apr 2006 15:34:17 -0700 Subject: [IronPython] Calling Win32 API in IronPython In-Reply-To: Message-ID: <4039D552ADAB094BB1EA670F3E96214E02ADD78A@df-foxhound-msg.exchange.corp.microsoft.com> Unfortunately we don't have a good way for you to do this directly from Python right now. I've opened a bug to track it as a future feature request, but I don't know when we'd get around to this. As a work around you could write a C# stub that interops w/ Win32 via DllImport (if you go this route be sure to check out http://pinvoke.net to see if they've got the signatures for your API already). Then you can just compile this and use that stub directly from IronPython: import clr clr.AddReferenceToFile('MyDll.dll') from MyDllsNameSpace import * and you have the wrapper types available to you to use from Python. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Quantum Infinity Sent: Thursday, April 27, 2006 2:06 PM To: users at lists.ironpython.com Subject: [IronPython] Calling Win32 API in IronPython Hi All, This is my first post here and I hope this question was not asked before. Anyway, is there any way to call a Win32 API in IronPython? I was trying to search Google along the lines of DllImport and DLLImportAttribute but I could not find and working example. I also tried to use the samples from Boo but I couldn't make it to work in IronPython. In CPython, i can use CTypes and call Win32 API but I just am really lost with IronPython. Regards, Quantufinity _________________________________________________________________ Don?t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/ From quantufinity at hotmail.com Fri Apr 28 02:25:55 2006 From: quantufinity at hotmail.com (Quantum Infinity) Date: Thu, 27 Apr 2006 19:25:55 -0500 Subject: [IronPython] Calling Win32 API in IronPython In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E02ADD78A@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: Thanks Dino. I was actually thinking of doing just that but I thought that there could be an easy way. Again thanks for the information. Hope IronPython will progess and become one of the best scripting languages for .Net platform. -Quantufinity >From: Dino Viehland >Reply-To: Discussion of IronPython >To: Discussion of IronPython >Subject: Re: [IronPython] Calling Win32 API in IronPython >Date: Thu, 27 Apr 2006 15:34:17 -0700 > >Unfortunately we don't have a good way for you to do this directly from >Python right now. I've opened a bug to track it as a future feature >request, but I don't know when we'd get around to this. > >As a work around you could write a C# stub that interops w/ Win32 via >DllImport (if you go this route be sure to check out http://pinvoke.net to >see if they've got the signatures for your API already). Then you can just >compile this and use that stub directly from IronPython: > >import clr >clr.AddReferenceToFile('MyDll.dll') >from MyDllsNameSpace import * > >and you have the wrapper types available to you to use from Python. > > > >Do you want to help develop Dynamic languages on CLR? >(http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) > >-----Original Message----- >From: users-bounces at lists.ironpython.com >[mailto:users-bounces at lists.ironpython.com] On Behalf Of Quantum Infinity >Sent: Thursday, April 27, 2006 2:06 PM >To: users at lists.ironpython.com >Subject: [IronPython] Calling Win32 API in IronPython > >Hi All, > >This is my first post here and I hope this question was not asked before. > >Anyway, is there any way to call a Win32 API in IronPython? I was trying to >search Google along the lines of DllImport and DLLImportAttribute but I >could not find and working example. I also tried to use the samples from >Boo >but I couldn't make it to work in IronPython. > >In CPython, i can use CTypes and call Win32 API but I just am really lost >with IronPython. > >Regards, >Quantufinity > >_________________________________________________________________ >Don?t just search. Find. Check out the new MSN Search! >http://search.msn.click-url.com/go/onm00200636ave/direct/01/ > >_______________________________________________ >users mailing list >users at lists.ironpython.com >http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _________________________________________________________________ FREE pop-up blocking with the new MSN Toolbar ? get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/ From textdirected at gmail.com Fri Apr 28 03:28:38 2006 From: textdirected at gmail.com (HEMMI, Shigeru) Date: Fri, 28 Apr 2006 10:28:38 +0900 Subject: [IronPython] Array element access of C# extension. Message-ID: Hello group, I wish to access each element value of single-dimension array in C# extension from IP. For example, a static method foo.goo defined in C# code, // fooLib.cs using System; namespace fooLib { public static class foo { public static void goo(int n, double[] x, double[] y) { for(int i=0; i Message-ID: You can try this: >>> import System >>> array = System.Array >>> x = array[float](range(5)) >>> x System.Double[](0.0, 1.0, 2.0, 3.0, 4.0) Or >>> System.Array.CreateInstance(float, 5) System.Double[](0.0, 0.0, 0.0, 0.0, 0.0) >>> x = System.Array.CreateInstance(float, 5) >>> x[0] = 10 -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of HEMMI, Shigeru Sent: Thursday, April 27, 2006 6:29 PM To: Discussion of IronPython Subject: [IronPython] Array element access of C# extension. Hello group, I wish to access each element value of single-dimension array in C# extension from IP. For example, a static method foo.goo defined in C# code, // fooLib.cs using System; namespace fooLib { public static class foo { public static void goo(int n, double[] x, double[] y) { for(int i=0; i References: Message-ID: Dear Haibo Luo, Thank you very much, I was able to do what I wanted. (Your reply was surprisingly quick!!) >>> import sys >>> sys.path.append(r'C:\testing') >>> import clr >>> clr.AddReferenceToFile('fooLib.dll') >>> import System >>> x = System.Array.CreateInstance(float, 10) >>> y = System.Array.CreateInstance(float, 10) >>> from fooLib import * >>> foo.goo(10,x,y) >>> x System.Double[](0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0) >>> y System.Double[](1.#INF, 1.0, 0.5, 0.333333333333, 0.25, 0.2, 0.166666666667, 0.1 42857142857, 0.125, 0.111111111111) >>> From s.kobalczyk at softwaremind.pl Fri Apr 28 07:09:42 2006 From: s.kobalczyk at softwaremind.pl (Szymon Kobalczyk) Date: Fri, 28 Apr 2006 07:09:42 +0200 Subject: [IronPython] Generated IL is always using the standard input, output and error streams. In-Reply-To: <4039D552ADAB094BB1EA670F3E96214E02A3CD88@df-foxhound-msg.exchange.corp.microsoft.com> References: <4039D552ADAB094BB1EA670F3E96214E02A3CD88@df-foxhound-msg.exchange.corp.microsoft.com> Message-ID: <4451A396.2030806@softwaremind.pl> Dino Viehland napisa?(a): > > The engine does have a SetStderr / SetStdout / SetStdin API which should be used for this purpose. And the nice thing is as we rev to the multi-System state module this API will remain unchanged so you won't be broken in the future. > Note that I the sample I've sent you, I use this API in PythonConsole_Load to initialize it with TexboxStreams like this: engine = new PythonEngine(); engine.MyConsole = this; engine.SetStdout(new TextboxStream(this.output, false)); engine.SetStderr(new TextboxStream(this.output, true)); This API is the preferred way to get output from IronPython code. But when you create a console there is additional text that engine may want to output like command prompts. For this I also implement IConsole interface on the PythonConsole control. It also allows the engine to collect interactive input. Szymon. From michael.foord at resolversystems.com Fri Apr 28 11:10:04 2006 From: michael.foord at resolversystems.com (Michael Foord) Date: Fri, 28 Apr 2006 10:10:04 +0100 Subject: [IronPython] time module Message-ID: <4451DBEC.7080301@resolversystems.com> Hello all, I was surprised to note that the IronPython module provides dramatically less resolution than the cPython equivalent. Both ``time.time()`` and ``time.clock()`` provide a resolution of only tenths of a second. This module is obviously heavily dependent on the underlying platform. In fact the standard Python docs warn, of ``time.time`` : Return the time as a floating point number expressed in seconds since the epoch, in UTC. Note that even though the time is always returned as a floating point number, not all systems provide time with a better precision than 1 second. While this function normally returns non-decreasing values, it can return a lower value than a previous call if the system clock has been set back between the two calls. *However*, of ``time.clock()``, the docs say : On Unix, return the current processor time as a floating point number expressed in seconds. The precision, and in fact the very definition of the meaning of ``processor time'', depends on that of the C function of the same name, but in any case, this is the function to use for benchmarking Python or timing algorithms. On Windows, this function returns wall-clock seconds elapsed since the first call to this function, as a floating point number, based on the Win32 function QueryPerformanceCounter(). The resolution is typically better than one microsecond. This means that ``time.clock()`` no longer functions usefully, or as described in the docs. For our profiling we started to use ``System.DateTime.Now``, but discovered this had a resolution of about 15ms. This was too small an increment for measuring some of our recursive functions. We ended up using ``QueryPerformanceCounter`` from C# [#]_. Would it be possible to re-implement ``time.clock`` so that it is useful ? Michael Foord .. [#] See the following page for basically full code to do this, http://www.codeproject.com/csharp/highperformancetimercshar.asp From mailinglist.account at gmail.com Fri Apr 28 12:04:23 2006 From: mailinglist.account at gmail.com (Anthony Tarlano) Date: Fri, 28 Apr 2006 12:04:23 +0200 Subject: [IronPython] Bug: Builtin thread module incomplete Message-ID: The builtin IronPython thread module (./IronPython/Modules/thread.cs) is missing several module functions, such as 'start_new', 'exit_thread' and 'allocate'. (see below) The missing 'start_new' is causing some cpython scripts not to run for me on IronPython. Is this going to be fixed for 1.0? CPC220# python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import thread; dir(thread) ['LockType', '__doc__', '__name__', '_local', 'allocate', 'allocate_lock', 'erro r', 'exit', 'exit_thread', 'get_ident', 'interrupt_main', 'start_new', 'start_ne w_thread'] >>> ^Z CPC220# python.net IronPython 1.0.60420 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import thread; dir(thread) ['Equals', 'Finalize', 'GetHashCode', 'GetType', 'LockType', 'MemberwiseClone', 'ToString', '__builtins__', '__class__', '__dict__', '__init__', '__module__', ' __name__', 'allocate_lock', 'error', 'exit', 'get_ident', 'interrupt_main', 'loc k', 'start_new_thread'] >>> ^Z From dinov at exchange.microsoft.com Fri Apr 28 17:23:18 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 28 Apr 2006 08:23:18 -0700 Subject: [IronPython] Generated IL is always using the standard input, output and error streams. In-Reply-To: <4451A396.2030806@softwaremind.pl> Message-ID: <4039D552ADAB094BB1EA670F3E96214E02ADDA15@df-foxhound-msg.exchange.corp.microsoft.com> Ahh, we'll want to consider routing that output through sys as well - it's a little more complicated for the super console though. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Szymon Kobalczyk Sent: Thursday, April 27, 2006 10:10 PM To: Discussion of IronPython Subject: Re: [IronPython] Generated IL is always using the standard input, output and error streams. Dino Viehland napisa?(a): > > The engine does have a SetStderr / SetStdout / SetStdin API which should be used for this purpose. And the nice thing is as we rev to the multi-System state module this API will remain unchanged so you won't be broken in the future. > Note that I the sample I've sent you, I use this API in PythonConsole_Load to initialize it with TexboxStreams like this: engine = new PythonEngine(); engine.MyConsole = this; engine.SetStdout(new TextboxStream(this.output, false)); engine.SetStderr(new TextboxStream(this.output, true)); This API is the preferred way to get output from IronPython code. But when you create a console there is additional text that engine may want to output like command prompts. For this I also implement IConsole interface on the PythonConsole control. It also allows the engine to collect interactive input. Szymon. _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Fri Apr 28 17:27:19 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 28 Apr 2006 08:27:19 -0700 Subject: [IronPython] time module In-Reply-To: <4451DBEC.7080301@resolversystems.com> Message-ID: <4039D552ADAB094BB1EA670F3E96214E02ADDA1B@df-foxhound-msg.exchange.corp.microsoft.com> Yes, it should be possible - .NET provides us the Stopwatch class for this reason in 2.0. I've opened a beta 7 bug for this. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Friday, April 28, 2006 2:10 AM To: Discussion of IronPython Subject: [IronPython] time module Hello all, I was surprised to note that the IronPython module provides dramatically less resolution than the cPython equivalent. Both ``time.time()`` and ``time.clock()`` provide a resolution of only tenths of a second. This module is obviously heavily dependent on the underlying platform. In fact the standard Python docs warn, of ``time.time`` : Return the time as a floating point number expressed in seconds since the epoch, in UTC. Note that even though the time is always returned as a floating point number, not all systems provide time with a better precision than 1 second. While this function normally returns non-decreasing values, it can return a lower value than a previous call if the system clock has been set back between the two calls. *However*, of ``time.clock()``, the docs say : On Unix, return the current processor time as a floating point number expressed in seconds. The precision, and in fact the very definition of the meaning of ``processor time'', depends on that of the C function of the same name, but in any case, this is the function to use for benchmarking Python or timing algorithms. On Windows, this function returns wall-clock seconds elapsed since the first call to this function, as a floating point number, based on the Win32 function QueryPerformanceCounter(). The resolution is typically better than one microsecond. This means that ``time.clock()`` no longer functions usefully, or as described in the docs. For our profiling we started to use ``System.DateTime.Now``, but discovered this had a resolution of about 15ms. This was too small an increment for measuring some of our recursive functions. We ended up using ``QueryPerformanceCounter`` from C# [#]_. Would it be possible to re-implement ``time.clock`` so that it is useful ? Michael Foord .. [#] See the following page for basically full code to do this, http://www.codeproject.com/csharp/highperformancetimercshar.asp _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Fri Apr 28 17:31:35 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 28 Apr 2006 08:31:35 -0700 Subject: [IronPython] Bug: Builtin thread module incomplete In-Reply-To: Message-ID: <4039D552ADAB094BB1EA670F3E96214E02ADDA21@df-foxhound-msg.exchange.corp.microsoft.com> start_new, exit_thread and allocate all appear to be undocumented and their __doc__ says they're just obsolete synonyms, which explains how we missed them. But yes, we can make these call the correctly named versions so that old scripts don't have to be modified. I've opened a beta 7 bug for this so it should be fixed in the next release. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Anthony Tarlano Sent: Friday, April 28, 2006 3:04 AM To: Discussion of IronPython Subject: [IronPython] Bug: Builtin thread module incomplete The builtin IronPython thread module (./IronPython/Modules/thread.cs) is missing several module functions, such as 'start_new', 'exit_thread' and 'allocate'. (see below) The missing 'start_new' is causing some cpython scripts not to run for me on IronPython. Is this going to be fixed for 1.0? CPC220# python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import thread; dir(thread) ['LockType', '__doc__', '__name__', '_local', 'allocate', 'allocate_lock', 'erro r', 'exit', 'exit_thread', 'get_ident', 'interrupt_main', 'start_new', 'start_ne w_thread'] >>> ^Z CPC220# python.net IronPython 1.0.60420 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import thread; dir(thread) ['Equals', 'Finalize', 'GetHashCode', 'GetType', 'LockType', 'MemberwiseClone', 'ToString', '__builtins__', '__class__', '__dict__', '__init__', '__module__', ' __name__', 'allocate_lock', 'error', 'exit', 'get_ident', 'interrupt_main', 'loc k', 'start_new_thread'] >>> ^Z _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From smppms2002 at yahoo.com.cn Sat Apr 29 03:50:53 2006 From: smppms2002 at yahoo.com.cn (smppms2002) Date: Sat, 29 Apr 2006 09:50:53 +0800 (CST) Subject: [IronPython] some function not implement in cStringIO Message-ID: <20060429015053.44563.qmail@web15707.mail.cnb.yahoo.com> first ,thanks Dino a lot. bellowing is not implement functions: close closed flush isatty next readlines reset softspace tell truncate writelines ___________________________________________________________ ??1G??????????? http://cn.mail.yahoo.com/ From sanxiyn at gmail.com Sat Apr 29 04:09:34 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Sat, 29 Apr 2006 11:09:34 +0900 Subject: [IronPython] some function not implement in cStringIO In-Reply-To: <20060429015053.44563.qmail@web15707.mail.cnb.yahoo.com> References: <20060429015053.44563.qmail@web15707.mail.cnb.yahoo.com> Message-ID: <5b0248170604281909w6e772903w80dacc605d3e89ff@mail.gmail.com> 2006/4/29, smppms2002 wrote: > some function not implement in cStringIO For the time being, you can rebuild with IronPython/Modules/cStringIO.cs removed, and put a stub cStringIO.py that imports everything from StringIO. (That's what I am currently doing.) cStringIO is strictly an optimization and doesn't change any semantics. Well, actually it does, but it's CPython's fault... See Python bug #1191420 for an example. (There are others, but they properly belong to Python arcana, not to any concern of IronPython developers, I think.) Seo Sanghyeon From smppms2002 at yahoo.com.cn Sat Apr 29 04:14:57 2006 From: smppms2002 at yahoo.com.cn (smppms2002) Date: Sat, 29 Apr 2006 10:14:57 +0800 (CST) Subject: [IronPython] writing and reading file performance test Message-ID: <20060429021457.88608.qmail@web15704.mail.cnb.yahoo.com> I do a writing and reading file performance test, the result is that python2.3 is more faster than ironpython1.0 beta6. test result of python2.3 : write & read [00005] M time used: w: average=[1.363979] std.deviation=[0.383529] max=[1.930142] min=[0.961854] r: average=[0.682326] std.deviation=[0.467239] max=[1.382589] min=[0.275619] test result of ironpython1.6 beta: write & read [00005] M time used: w: average=[2.488578] std.deviation=[0.223175] max=[3.054382] min=[2.213188] r: average=[1.515179] std.deviation=[0.074947] max=[1.632347] min=[1.412018] bellowing is the test script: from cStringIO import StringIO import time import math def test_write(m): bclock = time.clock() mf = StringIO() for i in xrange( 1024*m ): mf.write( "*" * 1023 + "\n" ) f=open("test.txt", "w") f.write( mf.getvalue() ) f.close() #mf.close() return time.clock() - bclock def test_read(): bclock = time.clock() i = 0 f=open("test.txt", "r") for x in f.readlines(): i = i + 1 f.close() return time.clock() - bclock def get_avg( arr ): _sum = 0 for x in arr: _sum = _sum + x return _sum / len(arr) def get_test( arr ): _dev = 0 avg = get_avg( arr ) for x in arr: _dev = _dev + (avg - x) * (avg - x) _dev = math.sqrt( _dev / len( arr ) ) return avg, _dev, max(arr), min(arr) if __name__ == "__main__": m = 5 w_arr = [] r_arr = [] for i in range(10): print ">>> pass ", i + 1 w_arr.append( test_write(m) ) r_arr.append( test_read ( ) ) w_avg, w_std_dev, w_max, w_min = get_test( w_arr ) r_avg, r_std_dev, r_max, r_min = get_test( r_arr ) print "write & read [%05d] M time used:" %( m ) print "w: average=[%f] std.deviation=[%f] max=[%f] min=[%f]" % get_test( w_arr ) print "r: average=[%f] std.deviation=[%f] max=[%f] min=[%f]" % get_test( r_arr ) ___________________________________________________________ ??1G??????????? http://cn.mail.yahoo.com/ From sanxiyn at gmail.com Sat Apr 29 05:34:51 2006 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Sat, 29 Apr 2006 12:34:51 +0900 Subject: [IronPython] __getslice__ usage in sre_parse Message-ID: <5b0248170604282034k26827e3du91b4ce3f9f538828@mail.gmail.com> Hello, Python language reference 3.3.6 deprecates __getslice__. I think it's okay that UserList.py has it, but sre_parse shouldn't use it, no? __getslice__ is not implemented in IronPython and this breaks usage of _sre.py, a pure-Python implementation of _sre, on IronPython: http://ubique.ch/code/_sre/ _sre.py is needed for me because IronPython's own regex implementation using underlying .NET implementation is not compatible enough for my applications. I will write a separate bug report for this. It should be a matter of removing __getslice__ and adding isinstance(index, slice) check in __getitem__. I would very much appreciate it if this is fixed before Python 2.5. Seo Sanghyeon From lcm at spiralcomms.com Sun Apr 30 11:58:33 2006 From: lcm at spiralcomms.com (Cheemeng) Date: Sun, 30 Apr 2006 17:58:33 +0800 Subject: [IronPython] unicode bug? Message-ID: <44548A49.6050702@spiralcomms.com> hi, Sq2 = u'\xb2' u = unicode(Sq2) print u is Sq2 in CPython, the unicode function returns back the same str, in IP, an exception is thrown, UnicodeDecodeError: Unable to translate bytes [B2] at index 0 from specified code page to Unicode. regards, cheemeng From brian.d.lloyd at gmail.com Sat Apr 1 18:06:06 2006 From: brian.d.lloyd at gmail.com (Brian Lloyd) Date: Sat, 01 Apr 2006 16:06:06 -0000 Subject: [IronPython] Naming and resolution of generic types (complete!) In-Reply-To: <002c01c6553c$f378b250$6603a8c0@Dell9150> References: <65531D426735784F854EE658938A585302798CCA@MI8NYCMAIL03.Mi8.com> <002c01c6553c$f378b250$6603a8c0@Dell9150> Message-ID: <1c0b4a390604010806x6d91fd64q6803febbc6e1e342@mail.gmail.com> Well, I'd argue that its not about trying to be all things to all programmers - its about finding the most reasonable way to handle one of the (relatively few) ways that the meta-models of the CLR and Python don't match up well. In a way, this is not unlike the situation with methods. The fact that Python doesn't have a concept of overloaded methods causes potential ambiguity on the Python side, but luckily there is a relatively elegant solution in that most of the time the runtime can do the Right Thing on its own, and you can hint it with the [] syntax if you need to. I'd like to find a similarly nice solution to this problem, but there are more constraints here in that types are routinely named in import statements. That makes a solution much harder in that you only have a Python name to work with and not many sneaky tricks at your disposal :^/ The more I think about it, I think the best solution might have to be that given the following statement: from System.Bunnies import Bunny then the name 'Bunny' will be bound to something that is one of: - a (reflected) non-generic type (if there exists a non-generic type of that name and no generic type definitions with the same base name). This type can be instantiated with the standard () syntax. - a (reflected) generic type definition (if there exists a generic type definition with the given base name, and no non-generic type with that name). This generic type definition can be bound into a closed generic type using the [] syntax. Trying to instantiate a generic type def using () raises a TypeError. - an object that represents more than one reflected type (if there exists both a generic and a non-generic type with the same base name, or more than one generic type with the same base name). Calling this object with () would create an instance if there exists a non-generic type, else raise a TypeError. Using the [] syntax would produce a closed type. There could be some sort of syntax you could use to obtain a reference to a specific (but unbound and uninstantiated) encapsulated type. This seems like it retains the most simplicity for common uses, and moves most of the ambiguity into less common cases (mostly having to do with a 'reflection context', from either the CLR or Python perspective). For example, what do you see if you do dir() on this pseudo-type? What would you pass to a System.Reflection method that expected a Type? Those still need to be answered, but I'd argue that for the most part normal users of the type from Python won't have to worry about it if we do the above. explicit-is-better-than-implicit-except-when-its-not'ly, -Brian On 3/31/06, Thane Plummer wrote: > My vote is to keep Python pure, i.e. import SomeGeneric_TT or foo = > TwoParamGeneric<<2 are simply un-Pythonic. > > It is amusing that the .NET framework has incorporated a feature > --Generics-- that make it more useful, and indeed more like Python, and the > Python community is now trying to emulate a solution that has already been > solved in Python! OK, I'm generalizing and I recognize that there are > exceptions; but by and large, Generics give .NET programmers the flexibility > that Python users have always had. > > The vast majority of programming objectives can be met using plain old > Python. Really. > > A problem arises when there is a .NET system call or 3rd party library that > expects Generics in its interface. In those cases, why not just coerce the > native Python type and throw an exception if the programmer did something > stupid? > > >>> import generic_interface_lib > >>> int_list = [1, 2, 3, "Hey! A string!", 5, 6] > >>> result = generic_interface_lib.Plot(int_list) > Traceback (most recent call last): > File "", line 1, in ? > Do_Not_Be_A_Bozo Exception: function requires a list of numbers. > > Yes, I do know the answer to the previous question, but this seems to be a > more Pythonic solution. Brian's question makes me wonder if Python can be > all things to all programmers, and my thinking is: no, it can't. Trying to > make it so will just pollute the language. > > --Thane > > > -----Original Message----- > From: pythondotnet-bounces at python.org > [mailto:pythondotnet-bounces at python.org] On Behalf Of Brian Lloyd > Sent: Friday, March 31, 2006 3:43 PM > To: pythondotnet at python.org > Cc: users at lists.ironpython.com > Subject: [Python.NET] Naming and resolution of generic types (complete!) > > > Hi all - I'm cross-posting this to the IP list as the subject seems to > be an open issue there too. > > I'm working on generics support for Python for .NET, and there a couple > of thorny issues that could use some discussion regarding naming and > resolution of generic types. > > In C# you can explicitly name a generic type, a la Dictionary<,>. That > syntax won't work in Python, of course. Looking at IP, it seems to allow > the apparent Python name to be the unmangled IL name so you can > naturally use the name. > > The problem is that the mangled name is illegal as a python name, and > the unmangled name isn't guaranteed to be unique - you can potentially > have any number of generic types as well as a non-generic type with the > same base name in the same namespace: > > namespace Spam { > > public class SpamCan {} > public class SpamCan {} > public class SpamCan {} > ... > } > > I imagine that maybe IP has enough information available at compile-time > to do the right thing for some common usage (binding and instantiating > the types), but the overloaded name can still be ambiguous. A real-life > example of this is System.IComparable - in IP, it doesn't seem possible > to get to the non-generic version of IComparable anymore (or at least it > was not obvious to me how to do it): > > >>> import System > >>> System.IComparable > > > It seems like we need to figure out some acceptable way of spelling > generic type names explicitly in Python (an equivalent to IComparable<> > in C#) that works within the existing syntax. > > There don't appear to be a lot of great options :( It has to be a valid > Python name to work in an import statement, so that rules out strange > operator shenanigans akin to the [] hack used for generic type binding. > > One would be to mimic the existing IL mangling in some way, a la: > > >From System import IComparable # the non-generic type > >From System import IComparable_1 # the 1-param generic > > # or > from System import IComparable_T > from System.Collections.Generic import Dictionary_TT > > These are all pretty gross, and still don't totally prevent hiding of > legit non-generic classes with those names (though it makes it less > likely that names will be hidden than the current approach). > > I suppose another approach would be to continue to have only one type > end up with the simple name, but provide a way to disambiguate it after > the fact: > > >>> import System > >>> System.IComparable > > > >>> # abandon all hope, ye who enter here... > >>> NonGenericIComparable = System.IComparable<<0 > >>> OneParamGenericIComparable = System.IComparable<<1 > >>> TwoParamVersionIfThereWasOne = System.IComparable<<2 > > That feels to me like it violates Python Zen in several ways, though. > > Thoughts? > > > -Brian > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > From kristof.wagemans at gmail.com Sun Apr 2 23:03:59 2006 From: kristof.wagemans at gmail.com (Kristof Wagemans) Date: Sun, 02 Apr 2006 21:03:59 -0000 Subject: [IronPython] Bug with string encoding while redirecting to a custom stream Message-ID: <000c01c65698$f2c321d0$0f01a8c0@notebook> I needed to change the default ASCII encoding to Unicode because it removed all accented characters when sending data to my custom stream. While trying to get this to work I found the following problem. Use PythonEngine.SetStdout(), PythonEngine.SetStderr(), PythonEngine.SetStdin () to set your own custom stream. There is a PythonFile wrapper created around the stream with the default encoding specified. Then change the default encoding with sys.setdefaultencoding('utf_16_le'). The encoding of the PythonFile remains the same and it keeps sending data in the old format. I don't know how difficult it is to change this behavior and even if it's possible to change the encoding dynamically. An easy workaround for me is to change the default encoding first and then set the new streams. I'm only using sys.setdefaultencoding('utf_16_le') to specify the default encoding at startup of the PythonEngine. The setting that I want to change is inaccessible: DefaultEncoding is an internal value in SystemState. Maybe it would be a good idea to add this to the Options so that it's possible to directly start the PythonEngine with the desired encoding. ----- Something else: it would be nice if the __doc__ of enum's returned all the names of the constants instead of 'no documentation available'. -------------- next part -------------- An HTML attachment was scrubbed... URL: From detlef.stute at seatec-gmbh.com Mon Apr 3 11:22:01 2006 From: detlef.stute at seatec-gmbh.com (Detlef Stute) Date: Mon, 03 Apr 2006 09:22:01 -0000 Subject: [IronPython] Real python question Message-ID: <000001c65700$15ac55b0$c901a8c0@LAPDS> Hi all, I have a question about the differences in the behavior of the console . I use the following code ( spaces marked with dots): def Hello(): ..print 'Joh' ..print 'and now?' print 'Start' Hello() If I enter this at a console ( ironpythonconsole or python24) this will not work with the empty line ( or if I don't use the empty line) it will create an error at "print 'Start') because it expects an empty line at the end of a block. If a save that in a file and call the programs with the file as parameter, everything works fine. Is this behavior a "must have" or specified? The reason for my question is, that I split the python files into lines and pass them to the interpreter line by line ( as an Iconsole) to have the capabilities to interrupt/ pause the process and inform the user about the progress ( line counter). Detlef www.seatec-gmbh.com From opindd at hotmail.com Fri Apr 21 09:02:42 2006 From: opindd at hotmail.com (opin2 hu) Date: Fri, 21 Apr 2006 07:02:42 -0000 Subject: [IronPython] time.strftime have different output in Ironpython and Python Message-ID: IronPython 1.0.60420 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import time >>> time.strftime("%x %X", time.localtime() ) u'21 \u4e0b' >>> ActivePython 2.3.5 Build 236 (ActiveState Corp.) based on Python 2.3.5 (#62, Feb 9 2005, 16:17:08) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import time >>> time.strftime("%x %X", time.localtime() ) '04/21/06 14:30:46' >>> _________________________________________________________________ ??????????????? MSN Hotmail? http://www.hotmail.com From guido at python.org Sun Apr 30 17:30:57 2006 From: guido at python.org (Guido van Rossum) Date: Sun, 30 Apr 2006 15:30:57 -0000 Subject: [IronPython] [Python-Dev] __getslice__ usage in sre_parse In-Reply-To: <5b0248170604282034k26827e3du91b4ce3f9f538828@mail.gmail.com> References: <5b0248170604282034k26827e3du91b4ce3f9f538828@mail.gmail.com> Message-ID: On 4/28/06, Sanghyeon Seo wrote: > Hello, > > Python language reference 3.3.6 deprecates __getslice__. I think it's > okay that UserList.py has it, but sre_parse shouldn't use it, no? Well, as long as the deprecated code isn't removed, there's no reason why other library code shouldn't use it. So I disagree that technically there's a reason why sre_parse shouldn't use it. > __getslice__ is not implemented in IronPython and this breaks usage of > _sre.py, a pure-Python implementation of _sre, on IronPython: > http://ubique.ch/code/_sre/ > > _sre.py is needed for me because IronPython's own regex implementation > using underlying .NET implementation is not compatible enough for my > applications. I will write a separate bug report for this. > > It should be a matter of removing __getslice__ and adding > isinstance(index, slice) check in __getitem__. I would very much > appreciate it if this is fixed before Python 2.5. You can influence the fix yourself -- please write a patch (relative to Python 2.5a2 that was just released), submit it to Python's patch tracker on SourceForge (read python.org/dev first), and then sending an email here to alert the developers. This ought to be done well before the planned 2.5b1 release (see PEP 256 for the 2.5 release timeline). You should make sure that the patched Python 2.5 passes all unit tests before submitting your test. Good luck! -- --Guido van Rossum (home page: http://www.python.org/~guido/)