[IronPython] FW: FW: FW: returning inherited classes to .NET

2008-02-21 Thread Howland-Rose, Kyle
Thanks for your help so late Curt (not that I need a quick answer at
all).
 
I am sure I am missing something big-time here and "talking" as
cross-purposes, but, to my mind the reason I don't have a problem when
running from the command line is because all I am doing is running the
ipy.exe on the file which loads some assemblies, creates a class
definition and a function definition and then terminates without even
instantiating the class.  Is this what you mean by "running it
directly"?   
 
Thanks again,
Kyle



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Curt
Hagenlocher
Sent: Friday, 22 February 2008 4:55 PM
To: Discussion of IronPython
Subject: Re: [IronPython] FW: FW: returning inherited classes to .NET


If you're only getting the error under ASP.NET, then it's highly likely
that you're loading multiple copies of the same assembly, which is why
the CLR can't cast your Python class back to the VB base -- it literally
considers them to be two different classes.  This may be related to the
way ASP.NET makes shadow copies of your files, but there could be other
reasons as well (none of which, unfortunately, come to mind right now).
 
Using an interface instead of a base class would give you the same
results.

On Thu, Feb 21, 2008 at 9:44 PM, Howland-Rose, Kyle <
[EMAIL PROTECTED]> wrote:


It runs fine from the command line but then it does not do much
... yet.  For the moment I am simplifying it by removing IP :(
 
I wanted to so some moderately heavy reflection which to my
thinking should be easier from IP but I will use VB for now.  
 
I assume I *should* be able to return a derived python class to
VB?  Alternatively I could implement an interface.  How can IP implement
a .NET interface?
(All pointers to pre-existing doco warmly received :)
 
Thanks
Kyle




From: [EMAIL PROTECTED] [mailto:
[EMAIL PROTECTED] On Behalf Of Curt Hagenlocher

Sent: Friday, 22 February 2008 4:29 PM
To: Discussion of IronPython
Subject: Re: [IronPython] FW: returning inherited classes to
.NET


My apologies; I wasn't reading the code correctly.  That's
probably a sign that I should be going to bed. :)  Have you tried
simplifying your version just a little bit by running it directly rather
than through ASP.NET  ?

 
On Thu, Feb 21, 2008 at 8:43 PM, Howland-Rose, Kyle <
[EMAIL PROTECTED]> wrote:


Hi Curt,

Thanks for replying.  When I view the link I see the
following:

The .NET code creates the "Test" class and then runs the
python code
which imports the "Test" class a subclasses it to create
python class
"X".

Class "X" is then called and cast to type "Test" and
assigned to the
value obj.

Is this what you are looking at?

My code is pretty much identical.  The VB looks like:


Public MustInherit Class ChildControl
   Public Function Control() As WebControl
   Return Nothing
   End Function
   Public Function GetValue() As String
   Return Nothing
   End Function
   Public Function SetValue(ByVal value As Object) As
String
   Return Nothing
   End Function
End Class

Class IPReflection
   Private Shared Instance As IPReflection = Nothing
   Private PyEngine As PythonEngine
   Private PyModule As EngineModule

   Public Shared Function Inst() As IPReflection
   If Instance Is Nothing Then
   Instance = New IPReflection
   End If
   Return Instance
   End Function

   Private Sub New()
   Dim path As String =
HttpContext.Current.Request.MapPath(".")
   PyEngine = New PythonEngine
   PyEngine.AddToPath(path)
   PyModule = PyEngine.CreateModule
   PyEngine.DefaultModule = PyModule


PyEngine.ExecuteFile(HttpContext.Current.Request.MapPath("CustomControls
.py"))
   End Sub

   Public Function GetChildControl() As ChildControl
   Return

CType(Operations.Ops.Call(PyModule.Globals("GetControl")), ChildControl)
   End Function
End Class
 

Re: [IronPython] FW: FW: returning inherited classes to .NET

2008-02-21 Thread Curt Hagenlocher
If you're only getting the error under ASP.NET, then it's highly likely that
you're loading multiple copies of the same assembly, which is why the CLR
can't cast your Python class back to the VB base -- it literally considers
them to be two different classes.  This may be related to the way
ASP.NETmakes shadow copies of your files, but there could be other
reasons as well
(none of which, unfortunately, come to mind right now).

Using an interface instead of a base class would give you the same results.
On Thu, Feb 21, 2008 at 9:44 PM, Howland-Rose, Kyle <
[EMAIL PROTECTED]> wrote:

>  It runs fine from the command line but then it does not do much ... yet.
> For the moment I am simplifying it by removing IP :(
>
> I wanted to so some moderately heavy reflection which to my thinking
> should be easier from IP but I will use VB for now.
>
> I assume I *should* be able to return a derived python class to VB?
> Alternatively I could implement an interface.  How can IP implement a .NET
> interface?
> (All pointers to pre-existing doco warmly received :)
>
> Thanks
> Kyle
>
>  --
>  *From:* [EMAIL PROTECTED] [mailto:
> [EMAIL PROTECTED] *On Behalf Of *Curt Hagenlocher
> *Sent:* Friday, 22 February 2008 4:29 PM
> *To:* Discussion of IronPython
> *Subject:* Re: [IronPython] FW: returning inherited classes to .NET
>
>   My apologies; I wasn't reading the code correctly.  That's probably a
> sign that I should be going to bed. :)  Have you tried simplifying your
> version just a little bit by running it directly rather than through
> ASP.NET ?
>
>
> On Thu, Feb 21, 2008 at 8:43 PM, Howland-Rose, Kyle <
> [EMAIL PROTECTED]> wrote:
>
> > Hi Curt,
> >
> > Thanks for replying.  When I view the link I see the following:
> >
> > The .NET code creates the "Test" class and then runs the python code
> > which imports the "Test" class a subclasses it to create python class
> > "X".
> >
> > Class "X" is then called and cast to type "Test" and assigned to the
> > value obj.
> >
> > Is this what you are looking at?
> >
> > My code is pretty much identical.  The VB looks like:
> >
> >
> > Public MustInherit Class ChildControl
> >Public Function Control() As WebControl
> >Return Nothing
> >End Function
> >Public Function GetValue() As String
> >Return Nothing
> >End Function
> >Public Function SetValue(ByVal value As Object) As String
> >Return Nothing
> >End Function
> > End Class
> >
> > Class IPReflection
> >Private Shared Instance As IPReflection = Nothing
> >Private PyEngine As PythonEngine
> >Private PyModule As EngineModule
> >
> >Public Shared Function Inst() As IPReflection
> >If Instance Is Nothing Then
> >Instance = New IPReflection
> >End If
> >Return Instance
> >End Function
> >
> >Private Sub New()
> >Dim path As String = HttpContext.Current.Request.MapPath(".")
> >PyEngine = New PythonEngine
> >PyEngine.AddToPath(path)
> >PyModule = PyEngine.CreateModule
> >PyEngine.DefaultModule = PyModule
> >
> > PyEngine.ExecuteFile(HttpContext.Current.Request.MapPath("CustomControls
> > .py"))
> >End Sub
> >
> >Public Function GetChildControl() As ChildControl
> >Return
> > CType(Operations.Ops.Call(PyModule.Globals("GetControl")), ChildControl)
> >End Function
> > End Class
> >
> > And the python looks like:
> >
> > import clr
> > import sys
> >
> > clr.AddReference('System')
> > import System
> >
> > sys.path.append(sys.path[0] + "/bin")
> >
> > clr.AddReferenceToFile("WebControlLibrary.dll")
> > clr.AddReference('System.Web')
> >
> > from System.Web.UI.WebControls import Label
> >
> > from WebControlLibrary import ChildControl
> >
> > class LabelChildControl(ChildControl):
> >def __init__(self):
> >self.control = Label()
> >def Control(self):
> >return self.control
> >
> > def GetControl():
> >return LabelChildControl()
> >
> >
> > Thanks again,
> > Kyle
> >
> > 
> >
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Curt
> > Hagenlocher
> > Sent: Friday, 22 February 2008 3:08 PM
> > To: Discussion of IronPython
> > Subject: Re: [IronPython] returning inherited classes to .NET
> >
> >
> > The page in question doesn't seem to show what you describe -- deriving
> > a Python class from a C# class.  Maybe you could show us your sample
> > code?
> >
> >
> > On Thu, Feb 21, 2008 at 7:39 PM, Howland-Rose, Kyle
> > <[EMAIL PROTECTED]> wrote:
> >
> >
> >Hi all,
> >I am following
> >
> >
> > http://www.ironpython.info/index.php/Using_Python_Classes_from_.NET
> > 
> > but using VB.
> >
> >In VB I declare a class and derive a python 1.1 class from it
> > but when I return it I get the exception:
> >
> >"Unable to cast objec

[IronPython] FW: FW: returning inherited classes to .NET

2008-02-21 Thread Howland-Rose, Kyle
It runs fine from the command line but then it does not do much ... yet.
For the moment I am simplifying it by removing IP :(
 
I wanted to so some moderately heavy reflection which to my thinking
should be easier from IP but I will use VB for now.  
 
I assume I *should* be able to return a derived python class to VB?
Alternatively I could implement an interface.  How can IP implement a
.NET interface?
(All pointers to pre-existing doco warmly received :)
 
Thanks
Kyle



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Curt
Hagenlocher
Sent: Friday, 22 February 2008 4:29 PM
To: Discussion of IronPython
Subject: Re: [IronPython] FW: returning inherited classes to .NET


My apologies; I wasn't reading the code correctly.  That's probably a
sign that I should be going to bed. :)  Have you tried simplifying your
version just a little bit by running it directly rather than through 
ASP.NET  ?

 
On Thu, Feb 21, 2008 at 8:43 PM, Howland-Rose, Kyle <
[EMAIL PROTECTED]> wrote:


Hi Curt,

Thanks for replying.  When I view the link I see the following:

The .NET code creates the "Test" class and then runs the python
code
which imports the "Test" class a subclasses it to create python
class
"X".

Class "X" is then called and cast to type "Test" and assigned to
the
value obj.

Is this what you are looking at?

My code is pretty much identical.  The VB looks like:


Public MustInherit Class ChildControl
   Public Function Control() As WebControl
   Return Nothing
   End Function
   Public Function GetValue() As String
   Return Nothing
   End Function
   Public Function SetValue(ByVal value As Object) As String
   Return Nothing
   End Function
End Class

Class IPReflection
   Private Shared Instance As IPReflection = Nothing
   Private PyEngine As PythonEngine
   Private PyModule As EngineModule

   Public Shared Function Inst() As IPReflection
   If Instance Is Nothing Then
   Instance = New IPReflection
   End If
   Return Instance
   End Function

   Private Sub New()
   Dim path As String =
HttpContext.Current.Request.MapPath(".")
   PyEngine = New PythonEngine
   PyEngine.AddToPath(path)
   PyModule = PyEngine.CreateModule
   PyEngine.DefaultModule = PyModule


PyEngine.ExecuteFile(HttpContext.Current.Request.MapPath("CustomControls
.py"))
   End Sub

   Public Function GetChildControl() As ChildControl
   Return
CType(Operations.Ops.Call(PyModule.Globals("GetControl")),
ChildControl)
   End Function
End Class

And the python looks like:

import clr
import sys

clr.AddReference('System')
import System

sys.path.append(sys.path[0] + "/bin")

clr.AddReferenceToFile("WebControlLibrary.dll")
clr.AddReference('System.Web')

from System.Web.UI.WebControls import Label

from WebControlLibrary import ChildControl

class LabelChildControl(ChildControl):
   def __init__(self):
   self.control = Label()
   def Control(self):
   return self.control

def GetControl():
   return LabelChildControl()


Thanks again,
Kyle




From: [EMAIL PROTECTED]

[mailto:[EMAIL PROTECTED] On Behalf Of Curt
Hagenlocher
Sent: Friday, 22 February 2008 3:08 PM
To: Discussion of IronPython
Subject: Re: [IronPython] returning inherited classes to .NET



The page in question doesn't seem to show what you describe --
deriving
a Python class from a C# class.  Maybe you could show us your
sample
code?


On Thu, Feb 21, 2008 at 7:39 PM, Howland-Rose, Kyle
<[EMAIL PROTECTED]> wrote:


   Hi all,
   I am following



http://www.ironpython.info/index.php/Using_Python_Classes_from_.NET
<
http://www.ironpython.info/index.php/Using_Python_Classes_from_.NET>
but using VB.

   In VB I declare a class and derive a python 1.1 class
from it
but when I return it I get the exception:

   "Unable to cast object of type
'IronPython.NewTypes.WebControlLibrary.ChildControl_1' to type
'WebControlLibrary.ChildControl'."
   

Re: [IronPython] FW: returning inherited classes to .NET

2008-02-21 Thread Curt Hagenlocher
My apologies; I wasn't reading the code correctly.  That's probably a sign
that I should be going to bed. :)  Have you tried simplifying your version
just a little bit by running it directly rather than through
ASP.NET
?


On Thu, Feb 21, 2008 at 8:43 PM, Howland-Rose, Kyle <
[EMAIL PROTECTED]> wrote:

> Hi Curt,
>
> Thanks for replying.  When I view the link I see the following:
>
> The .NET code creates the "Test" class and then runs the python code
> which imports the "Test" class a subclasses it to create python class
> "X".
>
> Class "X" is then called and cast to type "Test" and assigned to the
> value obj.
>
> Is this what you are looking at?
>
> My code is pretty much identical.  The VB looks like:
>
>
> Public MustInherit Class ChildControl
>Public Function Control() As WebControl
>Return Nothing
>End Function
>Public Function GetValue() As String
>Return Nothing
>End Function
>Public Function SetValue(ByVal value As Object) As String
>Return Nothing
>End Function
> End Class
>
> Class IPReflection
>Private Shared Instance As IPReflection = Nothing
>Private PyEngine As PythonEngine
>Private PyModule As EngineModule
>
>Public Shared Function Inst() As IPReflection
>If Instance Is Nothing Then
>Instance = New IPReflection
>End If
>Return Instance
>End Function
>
>Private Sub New()
>Dim path As String = HttpContext.Current.Request.MapPath(".")
>PyEngine = New PythonEngine
>PyEngine.AddToPath(path)
>PyModule = PyEngine.CreateModule
>PyEngine.DefaultModule = PyModule
>
> PyEngine.ExecuteFile(HttpContext.Current.Request.MapPath("CustomControls
> .py"))
>End Sub
>
>Public Function GetChildControl() As ChildControl
>Return
> CType(Operations.Ops.Call(PyModule.Globals("GetControl")), ChildControl)
>End Function
> End Class
>
> And the python looks like:
>
> import clr
> import sys
>
> clr.AddReference('System')
> import System
>
> sys.path.append(sys.path[0] + "/bin")
>
> clr.AddReferenceToFile("WebControlLibrary.dll")
> clr.AddReference('System.Web')
>
> from System.Web.UI.WebControls import Label
>
> from WebControlLibrary import ChildControl
>
> class LabelChildControl(ChildControl):
>def __init__(self):
>self.control = Label()
>def Control(self):
>return self.control
>
> def GetControl():
>return LabelChildControl()
>
>
> Thanks again,
> Kyle
>
> 
>
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Curt
> Hagenlocher
> Sent: Friday, 22 February 2008 3:08 PM
> To: Discussion of IronPython
> Subject: Re: [IronPython] returning inherited classes to .NET
>
>
> The page in question doesn't seem to show what you describe -- deriving
> a Python class from a C# class.  Maybe you could show us your sample
> code?
>
>
> On Thu, Feb 21, 2008 at 7:39 PM, Howland-Rose, Kyle
> <[EMAIL PROTECTED]> wrote:
>
>
>Hi all,
>I am following
>
>
> http://www.ironpython.info/index.php/Using_Python_Classes_from_.NET
> 
> but using VB.
>
>In VB I declare a class and derive a python 1.1 class from it
> but when I return it I get the exception:
>
>"Unable to cast object of type
> 'IronPython.NewTypes.WebControlLibrary.ChildControl_1' to type
> 'WebControlLibrary.ChildControl'."
>
>The page referenced above just seems to cast the python class
> instance to the C# class instance but this does not work for me in VB.
>
>Any help would be appreciated :)
>
>Thanks,
>
>Kyle
>
>
>
>
> 
>
>Allens Arthur Robinson online: http://www.aar.com.au
> 
>
>This email is confidential and may be subject to legal or other
> professional privilege. It is also subject to copyright. If you have
> received it in error, confidentiality and privilege are not waived and
> you must not disclose or use the information in it. Please notify the
> sender by return email and delete it from your system. Any personal
> information in this email must be handled in accordance with the Privacy
> Act 1988 (Cth).
>
>
> 
> *
>
>
>
>
> 
>
>Allens Arthur Robinson online: http://www.aar.com.au
> 
>
>This email is confidential and may be subject to legal or other
> professional privilege. It is also subject to copyright. If you have
> received it in error, confidentiality and privilege are not waived and
> you must not disclose or use the information in it. Please notify the
> sender by return email and delete it from your system. Any personal
> information in this email

[IronPython] FW: returning inherited classes to .NET

2008-02-21 Thread Howland-Rose, Kyle
Hi Curt,
 
Thanks for replying.  When I view the link I see the following:
 
The .NET code creates the "Test" class and then runs the python code
which imports the "Test" class a subclasses it to create python class
"X".
 
Class "X" is then called and cast to type "Test" and assigned to the
value obj.
 
Is this what you are looking at?  
 
My code is pretty much identical.  The VB looks like:
 

Public MustInherit Class ChildControl
Public Function Control() As WebControl
Return Nothing
End Function
Public Function GetValue() As String
Return Nothing
End Function
Public Function SetValue(ByVal value As Object) As String
Return Nothing
End Function
End Class

Class IPReflection
Private Shared Instance As IPReflection = Nothing
Private PyEngine As PythonEngine
Private PyModule As EngineModule

Public Shared Function Inst() As IPReflection
If Instance Is Nothing Then
Instance = New IPReflection
End If
Return Instance
End Function

Private Sub New()
Dim path As String = HttpContext.Current.Request.MapPath(".")
PyEngine = New PythonEngine
PyEngine.AddToPath(path)
PyModule = PyEngine.CreateModule
PyEngine.DefaultModule = PyModule
 
PyEngine.ExecuteFile(HttpContext.Current.Request.MapPath("CustomControls
.py"))
End Sub

Public Function GetChildControl() As ChildControl
Return
CType(Operations.Ops.Call(PyModule.Globals("GetControl")), ChildControl)
End Function
End Class 
 
And the python looks like:
 
import clr
import sys

clr.AddReference('System')
import System

sys.path.append(sys.path[0] + "/bin")

clr.AddReferenceToFile("WebControlLibrary.dll")
clr.AddReference('System.Web')

from System.Web.UI.WebControls import Label

from WebControlLibrary import ChildControl

class LabelChildControl(ChildControl):
def __init__(self):
self.control = Label()
def Control(self):
return self.control

def GetControl():
return LabelChildControl() 
 
 
Thanks again,
Kyle 



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Curt
Hagenlocher
Sent: Friday, 22 February 2008 3:08 PM
To: Discussion of IronPython
Subject: Re: [IronPython] returning inherited classes to .NET


The page in question doesn't seem to show what you describe -- deriving
a Python class from a C# class.  Maybe you could show us your sample
code?


On Thu, Feb 21, 2008 at 7:39 PM, Howland-Rose, Kyle
<[EMAIL PROTECTED]> wrote:


Hi all,
I am following 


http://www.ironpython.info/index.php/Using_Python_Classes_from_.NET

but using VB. 

In VB I declare a class and derive a python 1.1 class from it
but when I return it I get the exception:

"Unable to cast object of type
'IronPython.NewTypes.WebControlLibrary.ChildControl_1' to type
'WebControlLibrary.ChildControl'."

The page referenced above just seems to cast the python class
instance to the C# class instance but this does not work for me in VB.

Any help would be appreciated :)

Thanks,

Kyle

 



 
Allens Arthur Robinson online: http://www.aar.com.au
 
 
This email is confidential and may be subject to legal or other
professional privilege. It is also subject to copyright. If you have
received it in error, confidentiality and privilege are not waived and
you must not disclose or use the information in it. Please notify the
sender by return email and delete it from your system. Any personal
information in this email must be handled in accordance with the Privacy
Act 1988 (Cth).
 


*

 



 
Allens Arthur Robinson online: http://www.aar.com.au
 
 
This email is confidential and may be subject to legal or other
professional privilege. It is also subject to copyright. If you have
received it in error, confidentiality and privilege are not waived and
you must not disclose or use the information in it. Please notify the
sender by return email and delete it from your system. Any personal
information in this email must be handled in accordance with the Privacy
Act 1988 (Cth).
 


*


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

___
Users m

Re: [IronPython] returning inherited classes to .NET

2008-02-21 Thread Curt Hagenlocher
The page in question doesn't seem to show what you describe -- deriving a
Python class from a C# class.  Maybe you could show us your sample code?

On Thu, Feb 21, 2008 at 7:39 PM, Howland-Rose, Kyle <
[EMAIL PROTECTED]> wrote:

>  Hi all,
>
> I am following
> http://www.ironpython.info/index.php/Using_Python_Classes_from_.NET but
> using VB.
>
> In VB I declare a class and derive a python 1.1 class from it but when I
> return it I get the exception:
>
> "Unable to cast object of type '
> IronPython.NewTypes.WebControlLibrary.ChildControl_1' to type '
> WebControlLibrary.ChildControl'."
>
> The page referenced above just seems to cast the python class instance to
> the C# class instance but this does not work for me in VB.
>
> Any help would be appreciated :)
>
> Thanks,
>
> Kyle
>
>
>
> 
>
> Allens Arthur Robinson online: http://www.aar.com.au
>
> This email is confidential and may be subject to legal or other
> professional privilege. It is also subject to copyright. If you have
> received it in error, confidentiality and privilege are not waived and you
> must not disclose or use the information in it. Please notify the sender by
> return email and delete it from your system. Any personal information in
> this email must be handled in accordance with the Privacy Act 1988 (Cth).
>
> *
>
>
>
> 
>
> Allens Arthur Robinson online: http://www.aar.com.au
>
> This email is confidential and may be subject to legal or other
> professional privilege. It is also subject to copyright. If you have
> received it in error, confidentiality and privilege are not waived and you
> must not disclose or use the information in it. Please notify the sender by
> return email and delete it from your system. Any personal information in
> this email must be handled in accordance with the Privacy Act 1988 (Cth).
>
> *
>
> ___
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
> ___
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] returning inherited classes to .NET

2008-02-21 Thread Howland-Rose, Kyle
Again but with subject, sorry :(



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Howland-Rose,
Kyle
Sent: Friday, 22 February 2008 2:38 PM
To: users@lists.ironpython.com
Subject: [IronPython] (no subject)


Hi all, 

I am following 
http://www.ironpython.info/index.php/Using_Python_Classes_from_.NET

but using VB. 

In VB I declare a class and derive a python 1.1 class from it but when I
return it I get the exception: 

"Unable to cast object of type
'IronPython.NewTypes.WebControlLibrary.ChildControl_1' to type
'WebControlLibrary.ChildControl'." 

The page referenced above just seems to cast the python class instance
to the C# class instance but this does not work for me in VB. 

Any help would be appreciated :) 

Thanks, 

Kyle 

 


 
Allens Arthur Robinson online: http://www.aar.com.au
 
This email is confidential and may be subject to legal or other
professional privilege. It is also subject to copyright. If you have
received it in error, confidentiality and privilege are not waived and
you must not disclose or use the information in it. Please notify the
sender by return email and delete it from your system. Any personal
information in this email must be handled in accordance with the Privacy
Act 1988 (Cth).
 

*



 
Allens Arthur Robinson online: http://www.aar.com.au
 
This email is confidential and may be subject to legal or other professional 
privilege. It is also subject to copyright. If you have received it in error, 
confidentiality and privilege are not waived and you must not disclose or use 
the information in it. Please notify the sender by return email and delete it 
from your system. Any personal information in this email must be handled in 
accordance with the Privacy Act 1988 (Cth).
 
*
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] (no subject)

2008-02-21 Thread Howland-Rose, Kyle
Hi all, 

I am following
http://www.ironpython.info/index.php/Using_Python_Classes_from_.NET

but using VB. 

In VB I declare a class and derive a python 1.1 class from it but when I
return it I get the exception: 

"Unable to cast object of type
'IronPython.NewTypes.WebControlLibrary.ChildControl_1' to type
'WebControlLibrary.ChildControl'." 

The page referenced above just seems to cast the python class instance
to the C# class instance but this does not work for me in VB. 

Any help would be appreciated :) 

Thanks, 

Kyle 



 
Allens Arthur Robinson online: http://www.aar.com.au
 
This email is confidential and may be subject to legal or other professional 
privilege. It is also subject to copyright. If you have received it in error, 
confidentiality and privilege are not waived and you must not disclose or use 
the information in it. Please notify the sender by return email and delete it 
from your system. Any personal information in this email must be handled in 
accordance with the Privacy Act 1988 (Cth).
 
*
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Slow Performance of CPython libs?

2008-02-21 Thread Dino Viehland
After Birsh's last comment that they're calling compile I was thinking we might 
be doing something really stupid.  Turns out that we are.  For our supposedly 
compiled regex's we're not passing the Compiled option.  So they're all getting 
interpretted and of course that's going to suck big time.

So the fix for this is probably to just pass RegexOptions.Compiled to the Regex 
object being contructed into RE_Pattern.  Internally the Regex class will 
compile to dynamic methods (much better than compiling to an assembly because 
it'll be collectible).

It's actually a little more complex than that because we create RE_Pattern 
objects for the non-compiled so we need to flow the option in, but it's still a 
simple fix.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dan Shechter
Sent: Thursday, February 21, 2008 10:19 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Slow Performance of CPython libs?

Just out of curiosity...
I'm guessing that there are two levels of caching that could be used.
One would be to hold a global dictionary of some sort of pattern ->
Regex that will save the lengthy parsing of the re.

The other would be to actually call Regex.CompileToAssembly to get a
more efficient reperesentation (in runtime that is) of the re.

Would you (the IP team) favor the former or the latter?

Shechter.


Birsch wrote:
> I checked both sgmllib.py and BeautifulSoup.py - and it seems both are
> reusing the same regexps (searched for re.compile).
>
> I think your suggestion is very relevant in this case. It makes sense to
> replicate the "compile once use many" behavior that is commonly used
> with regexp.
>
> -Birsch
>
> On Thu, Feb 21, 2008 at 7:30 PM, Dino Viehland
> <[EMAIL PROTECTED] > wrote:
>
> Do you know if the same reg ex is being used repeatedly?  If so
> maybe we can cache & compile the regex instead of interpretting it
> all the time.
>
>
>
> *From:* [EMAIL PROTECTED]
> 
> [mailto:[EMAIL PROTECTED]
> ] *On Behalf Of *Birsch
> *Sent:* Thursday, February 21, 2008 8:30 AM
>
> *To:* Discussion of IronPython
> *Subject:* Re: [IronPython] Slow Performance of CPython libs?
>
>
>
> I took on Cooper's advice and profiled with ANTS. Here are the top
> methods:
>
> *Namespace*
>
>
>
> *Method name*
>
>
>
> *Time (sec.)*
>
>
>
> *Time with children (sec.)*
>
>
>
> *Hit count*
>
>
>
> *Source file*
>
> System.Text.RegularExpressions
>
>
>
> RegexInterpreter.Go()
>
>
>
> 37.0189
>
>
>
> 94.4676
>
>
>
> 13689612
>
>
>
> System.Text.RegularExpressions
>
>
>
> RegexInterpreter.Operator()
>
>
>
> 6.2411
>
>
>
> 6.2411
>
>
>
> 131146274
>
>
>
> System.Text.RegularExpressions
>
>
>
> RegexInterpreter.Advance(int i)
>
>
>
> 5.9264
>
>
>
> 8.7202
>
>
>
> 66000263
>
>
>
> System.Text.RegularExpressions
>
>
>
> RegexInterpreter.SetOperator(int op)
>
>
>
> 5.5750
>
>
>
> 5.5750
>
>
>
> 131146274
>
>
>
> System.Text.RegularExpressions
>
>
>
> RegexInterpreter.Backtrack()
>
>
>
> 5.5692
>
>
>
> 9.4895
>
>
>
> 37781343
>
>
>
> IronPython.Runtime.Operations
>
>
>
> Ops.CallWithContext(ICallerContext context, object func, object
> arg0, object arg1)
>
>
>
> 5.5572
>
>
>
> 114.5245
>
>
>
> 79754
>
>
>
> IronPython.Runtime.Calls
>
>
>
> Method.Call(ICallerContext context, object arg0)
>
>
>
> 4.9052
>
>
>
> 114.8251
>
>
>
> 50886
>
>
>
> IronPython.Runtime.Calls
>
>
>
> PythonFunction.CallInstance(ICallerContext context, object arg0,
> object arg1)
>
>
>
> 4.8876
>
>
>
> 114.8059
>
>
>
> 50886
>
>
>
> IronPython.Runtime.Calls
>
>
>
> Function2.Call(ICallerContext context, object arg0, object arg1)
>
>
>
> 4.6400
>
>
>
> 114.5471
>
>
>
> 47486
>
>
>
> IronPython.Runtime.Operations
>
>
>
> Ops.CallWithContext(ICallerContext context, object func, object arg0)
>
>
>
> 4.2344
>
>
>
> 114.1604
>
>
>
> 146658
>
>
>
> System.Text.RegularExpressions
>
>
>
> RegexBoyerMoore.Scan(string text, int index, int beglimit, int endlimit)
>
>
>
> 3.6465
>
>
>
> 3.6465
>
>
>
> 13678131
>
>
>
> System.Text.RegularExpressions
>
>
>
> RegexCharClass.CharInClassRecursive(char ch, string set, int start)
>
>
>
> 3.6288
>
>
>
> 5.7113
>
>
>
> 31508162
>
>
>
> System.Text.RegularExpressions
>
>
>
> RegexInterpreter.Goto(int newpos)
>
>
>
> 3.2058
>
>
>
> 5.1470
>
>
>
> 27364668
>
>
>
> System.Text.RegularExpressions
>
>
>
> RegexInterpreter.Operand(int i)
>
>
>
> 3.1923
>
>
>
> 3.1923
>
>
>
> 73230687
>
>
>
> System.Text.RegularExpressions
>
>
>
> RegexRunner.EnsureStorage()
>
>
>
> 3.0803
>
>
>
> 3.0803
>
>
>
> 51474823
>
>
>
> System.Tex

Re: [IronPython] Slow Performance of CPython libs?

2008-02-21 Thread Dan Shechter
Just out of curiosity...
I'm guessing that there are two levels of caching that could be used.
One would be to hold a global dictionary of some sort of pattern -> 
Regex that will save the lengthy parsing of the re.

The other would be to actually call Regex.CompileToAssembly to get a 
more efficient reperesentation (in runtime that is) of the re.

Would you (the IP team) favor the former or the latter?

Shechter.


Birsch wrote:
> I checked both sgmllib.py and BeautifulSoup.py - and it seems both are 
> reusing the same regexps (searched for re.compile).
> 
> I think your suggestion is very relevant in this case. It makes sense to 
> replicate the "compile once use many" behavior that is commonly used 
> with regexp.
> 
> -Birsch
> 
> On Thu, Feb 21, 2008 at 7:30 PM, Dino Viehland 
> <[EMAIL PROTECTED] > wrote:
> 
> Do you know if the same reg ex is being used repeatedly?  If so
> maybe we can cache & compile the regex instead of interpretting it
> all the time.
> 
>  
> 
> *From:* [EMAIL PROTECTED]
> 
> [mailto:[EMAIL PROTECTED]
> ] *On Behalf Of *Birsch
> *Sent:* Thursday, February 21, 2008 8:30 AM
> 
> *To:* Discussion of IronPython
> *Subject:* Re: [IronPython] Slow Performance of CPython libs?
> 
>  
> 
> I took on Cooper's advice and profiled with ANTS. Here are the top
> methods:
> 
> *Namespace*
> 
>   
> 
> *Method name*
> 
>   
> 
> *Time (sec.)*
> 
>   
> 
> *Time with children (sec.)*
> 
>   
> 
> *Hit count*
> 
>   
> 
> *Source file*
> 
> System.Text.RegularExpressions
> 
>   
> 
> RegexInterpreter.Go()
> 
>   
> 
> 37.0189
> 
>   
> 
> 94.4676
> 
>   
> 
> 13689612
> 
>   
> 
> System.Text.RegularExpressions
> 
>   
> 
> RegexInterpreter.Operator()
> 
>   
> 
> 6.2411
> 
>   
> 
> 6.2411
> 
>   
> 
> 131146274
> 
>   
> 
> System.Text.RegularExpressions
> 
>   
> 
> RegexInterpreter.Advance(int i)
> 
>   
> 
> 5.9264
> 
>   
> 
> 8.7202
> 
>   
> 
> 66000263
> 
>   
> 
> System.Text.RegularExpressions
> 
>   
> 
> RegexInterpreter.SetOperator(int op)
> 
>   
> 
> 5.5750
> 
>   
> 
> 5.5750
> 
>   
> 
> 131146274
> 
>   
> 
> System.Text.RegularExpressions
> 
>   
> 
> RegexInterpreter.Backtrack()
> 
>   
> 
> 5.5692
> 
>   
> 
> 9.4895
> 
>   
> 
> 37781343
> 
>   
> 
> IronPython.Runtime.Operations
> 
>   
> 
> Ops.CallWithContext(ICallerContext context, object func, object
> arg0, object arg1)
> 
>   
> 
> 5.5572
> 
>   
> 
> 114.5245
> 
>   
> 
> 79754
> 
>   
> 
> IronPython.Runtime.Calls
> 
>   
> 
> Method.Call(ICallerContext context, object arg0)
> 
>   
> 
> 4.9052
> 
>   
> 
> 114.8251
> 
>   
> 
> 50886
> 
>   
> 
> IronPython.Runtime.Calls
> 
>   
> 
> PythonFunction.CallInstance(ICallerContext context, object arg0,
> object arg1)
> 
>   
> 
> 4.8876
> 
>   
> 
> 114.8059
> 
>   
> 
> 50886
> 
>   
> 
> IronPython.Runtime.Calls
> 
>   
> 
> Function2.Call(ICallerContext context, object arg0, object arg1)
> 
>   
> 
> 4.6400
> 
>   
> 
> 114.5471
> 
>   
> 
> 47486
> 
>   
> 
> IronPython.Runtime.Operations
> 
>   
> 
> Ops.CallWithContext(ICallerContext context, object func, object arg0)
> 
>   
> 
> 4.2344
> 
>   
> 
> 114.1604
> 
>   
> 
> 146658
> 
>   
> 
> System.Text.RegularExpressions
> 
>   
> 
> RegexBoyerMoore.Scan(string text, int index, int beglimit, int endlimit)
> 
>   
> 
> 3.6465
> 
>   
> 
> 3.6465
> 
>   
> 
> 13678131
> 
>   
> 
> System.Text.RegularExpressions
> 
>   
> 
> RegexCharClass.CharInClassRecursive(char ch, string set, int start)
> 
>   
> 
> 3.6288
> 
>   
> 
> 5.7113
> 
>   
> 
> 31508162
> 
>   
> 
> System.Text.RegularExpressions
> 
>   
> 
> RegexInterpreter.Goto(int newpos)
> 
>   
> 
> 3.2058
> 
>   
> 
> 5.1470
> 
>   
> 
> 27364668
> 
>   
> 
> System.Text.RegularExpressions
> 
>   
> 
> RegexInterpreter.Operand(int i)
> 
>   
> 
> 3.1923
> 
>   
> 
> 3.1923
> 
>   
> 
> 73230687
> 
>   
> 
> System.Text.RegularExpressions
> 
>   
> 
> RegexRunner.EnsureStorage()
> 
>   
> 
> 3.0803
> 
>   
> 
> 3.0803
> 
>   
> 
> 51474823
> 
>   
> 
> System.Text.RegularExpressions
> 
>   
> 
> RegexCharClass.CharInClass(char ch, string set)
> 
>   
> 
> 3.0713
> 
>   
> 
> 8.7827
> 
>   
> 
> 31508162
> 
>   
> 
> IronPython.Runtime.

Re: [IronPython] Slow Performance of CPython libs?

2008-02-21 Thread Birsch
I checked both sgmllib.py and BeautifulSoup.py - and it seems both are
reusing the same regexps (searched for re.compile).

I think your suggestion is very relevant in this case. It makes sense to
replicate the "compile once use many" behavior that is commonly used with
regexp.

-Birsch

On Thu, Feb 21, 2008 at 7:30 PM, Dino Viehland <[EMAIL PROTECTED]>
wrote:

>  Do you know if the same reg ex is being used repeatedly?  If so maybe we
> can cache & compile the regex instead of interpretting it all the time.
>
>
>
> *From:* [EMAIL PROTECTED] [mailto:
> [EMAIL PROTECTED] *On Behalf Of *Birsch
> *Sent:* Thursday, February 21, 2008 8:30 AM
>
> *To:* Discussion of IronPython
> *Subject:* Re: [IronPython] Slow Performance of CPython libs?
>
>
>
> I took on Cooper's advice and profiled with ANTS. Here are the top
> methods:
>
> *Namespace*
>
> *Method name*
>
> *Time (sec.)*
>
> *Time with children (sec.)*
>
> *Hit count*
>
> *Source file*
>
> System.Text.RegularExpressions
>
> RegexInterpreter.Go()
>
> 37.0189
>
> 94.4676
>
> 13689612
>
> System.Text.RegularExpressions
>
> RegexInterpreter.Operator()
>
> 6.2411
>
> 6.2411
>
> 131146274
>
> System.Text.RegularExpressions
>
> RegexInterpreter.Advance(int i)
>
> 5.9264
>
> 8.7202
>
> 66000263
>
> System.Text.RegularExpressions
>
> RegexInterpreter.SetOperator(int op)
>
> 5.5750
>
> 5.5750
>
> 131146274
>
> System.Text.RegularExpressions
>
> RegexInterpreter.Backtrack()
>
> 5.5692
>
> 9.4895
>
> 37781343
>
> IronPython.Runtime.Operations
>
> Ops.CallWithContext(ICallerContext context, object func, object arg0,
> object arg1)
>
> 5.5572
>
> 114.5245
>
> 79754
>
> IronPython.Runtime.Calls
>
> Method.Call(ICallerContext context, object arg0)
>
> 4.9052
>
> 114.8251
>
> 50886
>
> IronPython.Runtime.Calls
>
> PythonFunction.CallInstance(ICallerContext context, object arg0, object
> arg1)
>
> 4.8876
>
> 114.8059
>
> 50886
>
> IronPython.Runtime.Calls
>
> Function2.Call(ICallerContext context, object arg0, object arg1)
>
> 4.6400
>
> 114.5471
>
> 47486
>
> IronPython.Runtime.Operations
>
> Ops.CallWithContext(ICallerContext context, object func, object arg0)
>
> 4.2344
>
> 114.1604
>
> 146658
>
> System.Text.RegularExpressions
>
> RegexBoyerMoore.Scan(string text, int index, int beglimit, int endlimit)
>
> 3.6465
>
> 3.6465
>
> 13678131
>
> System.Text.RegularExpressions
>
> RegexCharClass.CharInClassRecursive(char ch, string set, int start)
>
> 3.6288
>
> 5.7113
>
> 31508162
>
> System.Text.RegularExpressions
>
> RegexInterpreter.Goto(int newpos)
>
> 3.2058
>
> 5.1470
>
> 27364668
>
> System.Text.RegularExpressions
>
> RegexInterpreter.Operand(int i)
>
> 3.1923
>
> 3.1923
>
> 73230687
>
> System.Text.RegularExpressions
>
> RegexRunner.EnsureStorage()
>
> 3.0803
>
> 3.0803
>
> 51474823
>
> System.Text.RegularExpressions
>
> RegexCharClass.CharInClass(char ch, string set)
>
> 3.0713
>
> 8.7827
>
> 31508162
>
> IronPython.Runtime.Calls
>
> Method.Call(ICallerContext context, object arg0, object arg1)
>
> 2.9821
>
> 7.8675
>
> 15012
>
> IronPython.Runtime.Calls
>
> PythonFunction.CallInstance(ICallerContext context, object arg0, object
> arg1, object arg2)
>
> 2.9794
>
> 7.8639
>
> 15012
>
> System.Text.RegularExpressions
>
> RegexInterpreter.Forwardcharnext()
>
> 2.8852
>
> 2.8852
>
> 62865185
>
> System.Text.RegularExpressions
>
> RegexInterpreter.Forwardchars()
>
> 2.8279
>
> 2.8279
>
> 59436277
>
> System.Text.RegularExpressions
>
> RegexCharClass.CharInClassInternal(char ch, string set, int start, int
> mySetLength, int myCategoryLength)
>
> 2.0632
>
> 2.0826
>
> 31508162
>
> System.Text.RegularExpressions
>
> RegexRunner.Scan(Regex regex, string text, int textbeg, int textend, int
> textstart, int prevlen, bool quick)
>
> 1.8376
>
> 101.7226
>
> 43009
>
> System.Text.RegularExpressions
>
> RegexInterpreter.FindFirstChar()
>
> 1.6405
>
> 5.3456
>
> 13701755
>
> IronPython.Runtime.Types
>
> OldClass.TryLookupSlot(SymbolId name, out object ret)
>
> 1.5573
>
> 2.8124
>
> 389516
>
> IronPython.Runtime.Operations
>
> Ops.GetAttr(ICallerContext context, object o, SymbolId name)
>
> 1.5365
>
> 5.3456
>
> 558524
>
> System.Text.RegularExpressions
>
> RegexInterpreter.Textpos()
>
> 1.4020
>
> 1.4020
>
> 32648926
>
> System.Text.RegularExpressions
>
> RegexInterpreter.Advance()
>
> 1.1916
>
> 2.9526
>
> 13703950
>
> System.Text.RegularExpressions
>
> RegexInterpreter.Textto(int newpos)
>
> 1.1218
>
> 1.1218
>
> 24120890
>
> System.Text.RegularExpressions
>
> RegexInterpreter.TrackPeek()
>
> 1.0579
>
> 1.0579
>
> 24120894
>
> System.Text.RegularExpressions
>
> Regex.Run(bool quick, int prevlen, string input, int beginning, int
> length, int startat)
>
> 0.7280
>
> 102.4644
>
> 43009
>
> System.Text.RegularExpressions
>
> RegexInterpreter.TrackPush(int I1)
>
> 0.6834
>
> 0.6834
>
> 13745149
>
> System.Text.RegularExpressions
>
> RegexInterpreter.StackPush(int I1)
>
> 0.6542
>
> 0.6542
>
> 13703955
>
> System.Text.RegularExpressions
>
> RegexInterpreter.TrackPop()
>
> 0.6068
>
> 0.6

Re: [IronPython] Slow Performance of CPython libs?

2008-02-21 Thread Birsch
I took on Cooper's advice and profiled with ANTS. Here are the top methods:

Namespace Method name Time (sec.) Time with children (sec.) Hit count Source
file  System.Text.RegularExpressions RegexInterpreter.Go() 37.0189 94.4676
13689612
 System.Text.RegularExpressions RegexInterpreter.Operator() 6.2411 6.2411
131146274
 System.Text.RegularExpressions RegexInterpreter.Advance(int i) 5.9264
8.7202 66000263
 System.Text.RegularExpressions RegexInterpreter.SetOperator(int op) 5.5750
5.5750 131146274
 System.Text.RegularExpressions RegexInterpreter.Backtrack() 5.5692 9.4895
37781343
 IronPython.Runtime.Operations Ops.CallWithContext(ICallerContext context,
object func, object arg0, object arg1) 5.5572 114.5245 79754
 IronPython.Runtime.Calls Method.Call(ICallerContext context, object arg0)
4.9052 114.8251 50886
 IronPython.Runtime.Calls PythonFunction.CallInstance(ICallerContext
context, object arg0, object arg1) 4.8876 114.8059 50886
 IronPython.Runtime.Calls Function2.Call(ICallerContext context, object
arg0, object arg1) 4.6400 114.5471 47486
 IronPython.Runtime.Operations Ops.CallWithContext(ICallerContext context,
object func, object arg0) 4.2344 114.1604 146658
 System.Text.RegularExpressions RegexBoyerMoore.Scan(string text, int index,
int beglimit, int endlimit) 3.6465 3.6465 13678131
 System.Text.RegularExpressions RegexCharClass.CharInClassRecursive(char ch,
string set, int start) 3.6288 5.7113 31508162
 System.Text.RegularExpressions RegexInterpreter.Goto(int newpos) 3.2058
5.1470 27364668
 System.Text.RegularExpressions RegexInterpreter.Operand(int i) 3.1923
3.1923 73230687
 System.Text.RegularExpressions RegexRunner.EnsureStorage() 3.0803 3.0803
51474823
 System.Text.RegularExpressions RegexCharClass.CharInClass(char ch, string
set) 3.0713 8.7827 31508162
 IronPython.Runtime.Calls Method.Call(ICallerContext context, object arg0,
object arg1) 2.9821 7.8675 15012
 IronPython.Runtime.Calls PythonFunction.CallInstance(ICallerContext
context, object arg0, object arg1, object arg2) 2.9794 7.8639 15012
 System.Text.RegularExpressions RegexInterpreter.Forwardcharnext() 2.8852
2.8852 62865185
 System.Text.RegularExpressions RegexInterpreter.Forwardchars() 2.8279
2.8279 59436277
 System.Text.RegularExpressions RegexCharClass.CharInClassInternal(char ch,
string set, int start, int mySetLength, int myCategoryLength) 2.0632 2.0826
31508162
 System.Text.RegularExpressions RegexRunner.Scan(Regex regex, string text,
int textbeg, int textend, int textstart, int prevlen, bool quick) 1.8376
101.7226 43009
 System.Text.RegularExpressions RegexInterpreter.FindFirstChar() 1.6405
5.3456 13701755
 IronPython.Runtime.Types OldClass.TryLookupSlot(SymbolId name, out object
ret) 1.5573 2.8124 389516
 IronPython.Runtime.Operations Ops.GetAttr(ICallerContext context, object o,
SymbolId name) 1.5365 5.3456 558524
 System.Text.RegularExpressions RegexInterpreter.Textpos() 1.4020 1.4020
32648926
 System.Text.RegularExpressions RegexInterpreter.Advance() 1.1916 2.9526
13703950
 System.Text.RegularExpressions RegexInterpreter.Textto(int newpos) 1.1218
1.1218 24120890
 System.Text.RegularExpressions RegexInterpreter.TrackPeek() 1.0579 1.0579
24120894
 System.Text.RegularExpressions Regex.Run(bool quick, int prevlen, string
input, int beginning, int length, int startat) 0.7280 102.4644 43009
 System.Text.RegularExpressions RegexInterpreter.TrackPush(int I1) 0.6834
0.6834 13745149
 System.Text.RegularExpressions RegexInterpreter.StackPush(int I1) 0.6542
0.6542 13703955
 System.Text.RegularExpressions RegexInterpreter.TrackPop() 0.6068 0.6068
13663035
 System.Text.RegularExpressions RegexInterpreter.TrackPush() 0.6049 0.6049
13708230
 System.Text.RegularExpressions RegexInterpreter.StackPop() 0.5836 0.5836
13703956
 System.Text.RegularExpressions RegexInterpreter.Bump() 0.4987 0.4987
10472790
 System.Text.RegularExpressions RegexInterpreter.TrackPush(int I1, int I2)
0.4864 0.4864 10472790
 System.Text.RegularExpressions RegexInterpreter.TrackPeek(int i) 0.4663
0.4663 10457859
 System.Text.RegularExpressions RegexInterpreter.TrackPop(int framesize)
0.4396 0.4396 10457859

Moving up the stack of regex.Go(), most calls originate from sgmllib's
parse_starttag.

HTH,
-Birsch

On Thu, Feb 21, 2008 at 2:35 PM, Birsch <[EMAIL PROTECTED]> wrote:

> Thanks Michael and Dino.
>
> I'll prof and send update. Got a good profiler recommendation for .Net?
> Meanwhile I noticed the sample site below causes BeautifulSoup to generate
> quite a few [python] exceptions during __init__. Does IronPython handle
> exceptions significantly slower than CPtyhon?
>
> Repro code is simple (just build a BeautifulSoup obj with mininova's home
> page).
> Here are the .py and .cs I used to time the diffs:
>
> *bstest.py:*
> #Bypass CPython default socket implementation with IPCE/FePy
> import imp, os, sys
> sys.modules['socket'] = module = imp.new_module('socket')
> execfile('socket.py', module.__dict__)
>
> from BeautifulSoup import BeautifulSoup
> from urllib import u

Re: [IronPython] Slow Performance of CPython libs?

2008-02-21 Thread Dino Viehland
Throwing exceptions is a whole lot slower.  But for what it's worth the cost of 
try/except though is much cheaper on IronPython if no exception is thrown.  
Here's the exception results on PyBench.  Note these are actually results I 
happen to have on my machine from a while ago - but nothing's been done to 
change this part of the perf story in some time:

 TryExcept:56ms 3ms +1938.4%56ms 6ms +830.4%
TryRaiseExcept:88ms  2543ms  -96.6%88ms  2556ms  -96.5%

Cpython took 88ms, IronPython took 2543ms.  And clearly throwing exceptions is 
quite expensive.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Davy Mitchell
Sent: Thursday, February 21, 2008 4:55 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Slow Performance of CPython libs?

On Thu, Feb 21, 2008 at 12:35 PM, Birsch <[EMAIL PROTECTED]> wrote:
> quite a few [python] exceptions during __init__. Does IronPython handle
> exceptions significantly slower than CPtyhon?

This has been my experience - I've worked round it by editing modules
to avoid nasty bits.
Not always practical but saved many seconds in my case.

Cheers,
Davy

--
Davy Mitchell
Blog - http://www.latedecember.co.uk/sites/personal/davy/
Twitter - http://twitter.com/daftspaniel
Skype - daftspaniel needgod.com
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Slow Performance of CPython libs?

2008-02-21 Thread Jon Cooper
I like the ANTS Profiler, and there's also one in VS2005 Team that is supposed 
to be okay.

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Birsch
Sent: Thursday, February 21, 2008 7:36 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Slow Performance of CPython libs?

Thanks Michael and Dino.

I'll prof and send update. Got a good profiler recommendation for .Net?
Meanwhile I noticed the sample site below causes BeautifulSoup to generate 
quite a few [python] exceptions during __init__. Does IronPython handle 
exceptions significantly slower than CPtyhon?

Repro code is simple (just build a BeautifulSoup obj with mininova's home page).
Here are the .py and .cs I used to time the diffs:

bstest.py:
#Bypass CPython default socket implementation with IPCE/FePy
import imp, os, sys
sys.modules['socket'] = module = imp.new_module('socket')
execfile('socket.py', module.__dict__)

from BeautifulSoup import BeautifulSoup
from urllib import urlopen
import datetime

def getContent(url):
#Download html data
startTime = datetime.datetime.now()
print "Getting url", url
html = urlopen(url).read()
print "Time taken:", datetime.datetime.now() - startTime

#Make soup
startTime = datetime.datetime.now()
print "Making soup..."
soup = BeautifulSoup(markup=html)
print "Time taken:", datetime.datetime.now() - startTime

if __name__ == "__main__":
print getContent("www.mininova.org")


C#:
using System;
using System.Collections.Generic;
using System.Text;
using IronPython.Hosting;

namespace IronPythonBeautifulSoupTest
{
public class Program
{
public static void Main(string[] args)
{
//Init
System.Console.WriteLine("Starting...");
DateTime start = DateTime.Now;
PythonEngine engine = new PythonEngine();

//Add paths:
//BeautifulSoup.py, socket.py, bstest.py located on exe dir
engine.AddToPath(@".");
//CPython Lib (replace with your own)
engine.AddToPath(@"D:\Dev\Python\Lib");

//Import and load
TimeSpan span = DateTime.Now - start;
System.Console.WriteLine("[1] Import: " + span.TotalSeconds);
DateTime d = DateTime.Now;
engine.ExecuteFile(@"bstest.py");
span = DateTime.Now - d;
System.Console.WriteLine("[2] Load: " + span.TotalSeconds);

//Execute
d = DateTime.Now;

engine.Execute("getContent(\"http://www.mininova.org\")");
span = DateTime.Now - d;
System.Console.WriteLine("[3] Execute: " + span.TotalSeconds);
span = DateTime.Now - start;
System.Console.WriteLine("Total: " + span.TotalSeconds);
}
}
}


On Wed, Feb 20, 2008 at 6:57 PM, Dino Viehland <[EMAIL PROTECTED]> wrote:
We've actually had this issue reported once before a long time ago - it's a 
very low CodePlex ID - 
http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=651

We haven't had a chance to investigate the end-to-end scenario.  If someone 
could come up with a smaller simpler repro that'd be great.  Otherwise we 
haven't forgotten about it we've just had more immediately pressing issues to 
work on :(.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL 
PROTECTED]] On Behalf Of Michael Foord
Sent: Wednesday, February 20, 2008 5:20 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Slow Performance of CPython libs?

Birsch wrote:
> Hi - We've been using IronPython successfully to allow extensibility
> of our application.
>
> Overall we are happy with the performance, with the exception of
> BeautifulSoup which seems to run very slowly: x5 or more time to
> execute compared to CPython.
>
> Most of the time seems to be spent during __init__() of BS, where the
> markup is parsed.
>
> We suspect this has to do with the fact that our CPython env is
> executing .pyc files and can precompile its libs, while the IronPython
> environment compiles each iteration. We couldn't find a way to
> pre-compile the libs and then introduce them into the code, but in any
> case this will result in a large management overhead since the amount
> of CPython libs we expose to our users contains 100's of modules.
>
> Any ideas on how to optimize?

I think it is worth doing real profiling to find out where the time is
being spent during parsing.

If it is spending most of the time in '__init__' then the time is
probably not spent in importing - so compilation isn't relevant and it
is a runtime performance issue. (Importing is much slower with
IronPython and at Resolver Systems we do use precompiled binaries - but
strangely enough it doesn't provide much of a performance gain.)

Michael
http://www.manning.com/foord

>
> Thanks,
> -Birsch
>
> Note: we're usi

Re: [IronPython] Slow Performance of CPython libs?

2008-02-21 Thread Michael Foord
Birsch wrote:
> Thanks Michael and Dino.
>
> I'll prof and send update. Got a good profiler recommendation for .Net?
> Meanwhile I noticed the sample site below causes BeautifulSoup to 
> generate quite a few [python] exceptions during __init__. Does 
> IronPython handle exceptions significantly slower than CPtyhon?

I wouldn't make any assumptions about what is taking the time until you 
have profiled. :-)

Michael
http://www.manning.com/foord

>
> Repro code is simple (just build a BeautifulSoup obj with mininova's 
> home page).
> Here are the .py and .cs I used to time the diffs:
>
> *bstest.py:*
> #Bypass CPython default socket implementation with IPCE/FePy
> import imp, os, sys
> sys.modules['socket'] = module = imp.new_module('socket')
> execfile('socket.py', module.__dict__)
>
> from BeautifulSoup import BeautifulSoup
> from urllib import urlopen
> import datetime
>
> def getContent(url):
> #Download html data
> startTime = datetime.datetime.now()
> print "Getting url", url
> html = urlopen(url).read()
> print "Time taken:", datetime.datetime.now() - startTime
>
> #Make soup
> startTime = datetime.datetime.now()
> print "Making soup..."
> soup = BeautifulSoup(markup=html)
> print "Time taken:", datetime.datetime.now() - startTime
>
> if __name__ == "__main__":
> print getContent("www.mininova.org ")
>
>
> *C#:*
> using System;
> using System.Collections.Generic;
> using System.Text;
> using IronPython.Hosting;
>
> namespace IronPythonBeautifulSoupTest
> {
> public class Program
> {
> public static void Main(string[] args)
> {
> //Init
> System.Console.WriteLine("Starting...");
> DateTime start = DateTime.Now;
> PythonEngine engine = new PythonEngine();
>
> //Add paths:
> //BeautifulSoup.py, socket.py, bstest.py located on exe dir
> engine.AddToPath(@".");
> //CPython Lib (replace with your own)
> engine.AddToPath(@"D:\Dev\Python\Lib");
>
> //Import and load
> TimeSpan span = DateTime.Now - start;
> System.Console.WriteLine("[1] Import: " + span.TotalSeconds);
> DateTime d = DateTime.Now;
> engine.ExecuteFile(@"bstest.py");
> span = DateTime.Now - d;
> System.Console.WriteLine("[2] Load: " + span.TotalSeconds);
>
> //Execute
> d = DateTime.Now;
> engine.Execute("getContent(\"http://www.mininova.org\ 
> ")");
> span = DateTime.Now - d;
> System.Console.WriteLine("[3] Execute: " + span.TotalSeconds);
> span = DateTime.Now - start;
> System.Console.WriteLine("Total: " + span.TotalSeconds);
> }
> }
> }
>
>
>
> On Wed, Feb 20, 2008 at 6:57 PM, Dino Viehland 
> <[EMAIL PROTECTED] > 
> wrote:
>
> We've actually had this issue reported once before a long time ago
> - it's a very low CodePlex ID -
> http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=651
>
> We haven't had a chance to investigate the end-to-end scenario.
>  If someone could come up with a smaller simpler repro that'd be
> great.  Otherwise we haven't forgotten about it we've just had
> more immediately pressing issues to work on :(.
>
> -Original Message-
> From: [EMAIL PROTECTED]
> 
> [mailto:[EMAIL PROTECTED]
> ] On Behalf Of Michael
> Foord
> Sent: Wednesday, February 20, 2008 5:20 AM
> To: Discussion of IronPython
> Subject: Re: [IronPython] Slow Performance of CPython libs?
>
> Birsch wrote:
> > Hi - We've been using IronPython successfully to allow extensibility
> > of our application.
> >
> > Overall we are happy with the performance, with the exception of
> > BeautifulSoup which seems to run very slowly: x5 or more time to
> > execute compared to CPython.
> >
> > Most of the time seems to be spent during __init__() of BS,
> where the
> > markup is parsed.
> >
> > We suspect this has to do with the fact that our CPython env is
> > executing .pyc files and can precompile its libs, while the
> IronPython
> > environment compiles each iteration. We couldn't find a way to
> > pre-compile the libs and then introduce them into the code, but
> in any
> > case this will result in a large management overhead since the
> amount
> > of CPython libs we expose to our users contains 100's of modules.
> >
> > Any ideas on how to optimize?
>
> I think it is worth doing real profiling to find out where the time is
> being spent during parsing.
>
> If it is spending most of the time in '__init__' then the time is
> probably not spent in importing - so compilation isn't relevant and

Re: [IronPython] ironptython xml-rpc how?

2008-02-21 Thread Curt Hagenlocher
On Thu, Feb 21, 2008 at 4:35 AM,  <[EMAIL PROTECTED]> wrote:
>
>  File System, line unknown, in Read
> IOError: Unable to read data from the transport connection: Cannot access
> a disposed object.
> Object name: 'System.Net.Sockets.Socket'..

This is a known issue in IronPython.  You can work around it by using
Seo's implementation of the socket module.  If you're not already
using it, download "IronPython Community Edition" from
http://fepy.sourceforge.net.  Then to replace the built-in socket
module, you'll need to do something like this:

import os, sys, imp
sys.modules['socket'] = module = imp.new_module('socket')
execfile('..\\lib\\socket.py', module.__dict__)
import xmlrpclib
server = xmlrpclib.Server('http://localhost:4567')
month = server.getMonth(2002, 8)

I've tested this and it works.

(Code shamelessly stolen from Birsch's recent BeautifulSoup example.)

--
Curt Hagenlocher
[EMAIL PROTECTED]
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Slow Performance of CPython libs?

2008-02-21 Thread Davy Mitchell
On Thu, Feb 21, 2008 at 12:35 PM, Birsch <[EMAIL PROTECTED]> wrote:
> quite a few [python] exceptions during __init__. Does IronPython handle
> exceptions significantly slower than CPtyhon?

This has been my experience - I've worked round it by editing modules
to avoid nasty bits.
Not always practical but saved many seconds in my case.

Cheers,
Davy

-- 
Davy Mitchell
Blog - http://www.latedecember.co.uk/sites/personal/davy/
Twitter - http://twitter.com/daftspaniel
Skype - daftspaniel needgod.com
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] xmlrpc in ironpython how? sorry, the first thread there are little mistake in the code....

2008-02-21 Thread henry
hello there i'me newbie in ironpython. i'm just wondering, is there
any way that ironpython dealing with xml-rpc? cause i had imported
i tried to import xmlrpclib to ironpython with this code

import xmlprclib
server = xmlrpclib.Server("localhost:4567")
month = server.getMonth(2002, 8)

i got this error message :
Traceback (most recent call last):
  File System, line unknown, in Read
  File System, line unknown, in Receive
  File System, line unknown, in Receive
  File , line 0, in ##180
  File xmlrpclib, line unknown, in __call__
  File D:\Python24\Lib\xmlrpclib.py, line 1096, in __call__
  File D:\Python24\Lib\xmlrpclib.py, line 1379, in _ServerProxy__request
  File D:\Python24\Lib\xmlrpclib.py, line 1147, in request
  File D:\Python24\Lib\xmlrpclib.py, line 1276, in _parse_response
  File , line 0, in Read##177
  File System, line unknown, in Read
IOError: Unable to read data from the transport connection: Cannot access
a disp
osed object.
Object name: 'System.Net.Sockets.Socket'..

the code and the server n client are based on xmlrpc in python
based on http://www.ibm.com/developerworks/library/ws-pyth10.html

the server run on python 2.4
here is the code :

import  calendar, SimpleXMLRPCServer

#The server object
class Calendar:
def getMonth(self, year, month):
return calendar.month(year, month)

def getYear(self, year):
return calendar.calendar(year)


calendar_object = Calendar()
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("10.126.11.212", 4567))
server.register_instance(calendar_object)

#Go into the main listener loop
print "Listening on port 4567"
server.serve_forever()



the client run on ironpython 1.1.1 using xmlrpclib on python 2.4.4

import xmlrpclib

server = xmlrpclib.ServerProxy("http://10.126.11.212:4567";)

month = server.getMonth(2002, 8)
print month


can anyone help me with this problem or is there another way to implement
xmlprc client in ironpython ?



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


[IronPython] ironptython xml-rpc how?

2008-02-21 Thread henry
hello there i'me newbie in ironpython. i'm just wondering, is there
any way that ironpython dealing with xml-rpc? cause i had imported
i tried to import xmlrpclib to ironpython with this code

import xmlprclib
server = xmlrpclib.Server("localhost:4567")
month = server.getMonth(2002, 8)

i got this error message :
Traceback (most recent call last):
  File System, line unknown, in Read
  File System, line unknown, in Receive
  File System, line unknown, in Receive
  File , line 0, in ##180
  File xmlrpclib, line unknown, in __call__
  File D:\Python24\Lib\xmlrpclib.py, line 1096, in __call__
  File D:\Python24\Lib\xmlrpclib.py, line 1379, in _ServerProxy__request
  File D:\Python24\Lib\xmlrpclib.py, line 1147, in request
  File D:\Python24\Lib\xmlrpclib.py, line 1276, in _parse_response
  File , line 0, in Read##177
  File System, line unknown, in Read
IOError: Unable to read data from the transport connection: Cannot access
a disp
osed object.
Object name: 'System.Net.Sockets.Socket'..

the code and the server n client are based on xmlrpc in python
based on http://www.ibm.com/developerworks/library/ws-pyth10.html

the server run on python 2.4
here is the code :

import  calendar, SimpleXMLRPCServer

#The server object
class Calendar:
def getMonth(self, year, month):
return calendar.month(year, month)

def getYear(self, year):
return calendar.calendar(year)


calendar_object = Calendar()
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("10.126.11.212", 4567))
server.register_instance(calendar_object)

#Go into the main listener loop
print "Listening on port 4567"
server.serve_forever()



the client run on ironpython 1.1.1 using xmlrpclib on python 2.4.4

import xmlrpclib

server = xmlrpclib.ServerProxy("http://localhost:";)

month = server.getMonth(2002, 8)
print month


can anyone help me with this problem or is there another way to implement
xmlprc client in ironpython ?



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


Re: [IronPython] Slow Performance of CPython libs?

2008-02-21 Thread Birsch
Thanks Michael and Dino.

I'll prof and send update. Got a good profiler recommendation for .Net?
Meanwhile I noticed the sample site below causes BeautifulSoup to generate
quite a few [python] exceptions during __init__. Does IronPython handle
exceptions significantly slower than CPtyhon?

Repro code is simple (just build a BeautifulSoup obj with mininova's home
page).
Here are the .py and .cs I used to time the diffs:

*bstest.py:*
#Bypass CPython default socket implementation with IPCE/FePy
import imp, os, sys
sys.modules['socket'] = module = imp.new_module('socket')
execfile('socket.py', module.__dict__)

from BeautifulSoup import BeautifulSoup
from urllib import urlopen
import datetime

def getContent(url):
#Download html data
startTime = datetime.datetime.now()
print "Getting url", url
html = urlopen(url).read()
print "Time taken:", datetime.datetime.now() - startTime

#Make soup
startTime = datetime.datetime.now()
print "Making soup..."
soup = BeautifulSoup(markup=html)
print "Time taken:", datetime.datetime.now() - startTime

if __name__ == "__main__":
print getContent("www.mininova.org")


*C#:*
using System;
using System.Collections.Generic;
using System.Text;
using IronPython.Hosting;

namespace IronPythonBeautifulSoupTest
{
public class Program
{
public static void Main(string[] args)
{
//Init
System.Console.WriteLine("Starting...");
DateTime start = DateTime.Now;
PythonEngine engine = new PythonEngine();

//Add paths:
//BeautifulSoup.py, socket.py, bstest.py located on exe dir
engine.AddToPath(@".");
//CPython Lib (replace with your own)
engine.AddToPath(@"D:\Dev\Python\Lib");

//Import and load
TimeSpan span = DateTime.Now - start;
System.Console.WriteLine("[1] Import: " + span.TotalSeconds);
DateTime d = DateTime.Now;
engine.ExecuteFile(@"bstest.py");
span = DateTime.Now - d;
System.Console.WriteLine("[2] Load: " + span.TotalSeconds);

//Execute
d = DateTime.Now;
engine.Execute("getContent(\"http://www.mininova.org\";)");
span = DateTime.Now - d;
System.Console.WriteLine("[3] Execute: " + span.TotalSeconds);
span = DateTime.Now - start;
System.Console.WriteLine("Total: " + span.TotalSeconds);
}
}
}



On Wed, Feb 20, 2008 at 6:57 PM, Dino Viehland <[EMAIL PROTECTED]>
wrote:

> We've actually had this issue reported once before a long time ago - it's
> a very low CodePlex ID -
> http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=651
>
> We haven't had a chance to investigate the end-to-end scenario.  If
> someone could come up with a smaller simpler repro that'd be great.
>  Otherwise we haven't forgotten about it we've just had more immediately
> pressing issues to work on :(.
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:
> [EMAIL PROTECTED] On Behalf Of Michael Foord
> Sent: Wednesday, February 20, 2008 5:20 AM
> To: Discussion of IronPython
> Subject: Re: [IronPython] Slow Performance of CPython libs?
>
> Birsch wrote:
> > Hi - We've been using IronPython successfully to allow extensibility
> > of our application.
> >
> > Overall we are happy with the performance, with the exception of
> > BeautifulSoup which seems to run very slowly: x5 or more time to
> > execute compared to CPython.
> >
> > Most of the time seems to be spent during __init__() of BS, where the
> > markup is parsed.
> >
> > We suspect this has to do with the fact that our CPython env is
> > executing .pyc files and can precompile its libs, while the IronPython
> > environment compiles each iteration. We couldn't find a way to
> > pre-compile the libs and then introduce them into the code, but in any
> > case this will result in a large management overhead since the amount
> > of CPython libs we expose to our users contains 100's of modules.
> >
> > Any ideas on how to optimize?
>
> I think it is worth doing real profiling to find out where the time is
> being spent during parsing.
>
> If it is spending most of the time in '__init__' then the time is
> probably not spent in importing - so compilation isn't relevant and it
> is a runtime performance issue. (Importing is much slower with
> IronPython and at Resolver Systems we do use precompiled binaries - but
> strangely enough it doesn't provide much of a performance gain.)
>
> Michael
> http://www.manning.com/foord
>
> >
> > Thanks,
> > -Birsch
> >
> > Note: we're using FePy/IPCE libs with regular IP v1.1.1 runtime DLLs
> > (this was done to overcome library incompatibilities and network
> > errors). However, the relevant slow .py code (mainly SGMLParser and
> > BeautifulSoup) is the same.
> > 
> >
> >