473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Why Python won't work on .net

Jython is 100% java coded python.
Python objects work with javacompilers and Virtual machines.

I am a hobby programmer so the technical reasons are probably beyond me...
Why is python incompatible with .net? Why can't python be coded in C#?

I see the the MONO project on linux/unix is advancing. .Net seems to be a
juggernaut especially if programmers will be able to use their favorite(most
productive) language to program in. (every language but python)

I am a new python tinkerer. I love the language. But what is its future but as
a legacy tool?

allen
Jul 18 '05 #1
25 2095
al**********@aol.com (Allenabethea) writes:
Why is python incompatible with .net? Why can't python be coded in
C#?
Who says that it cannot be coded in C#. It is a matter of fact that it
currently isn't, but it would be possible to reimplement the Python
interpreter in C# (instead of implementing it in C).

As for generating MSIL byte codes: This is also possible, and has been
demonstrated. It also has been demonstrated that an initial
implementation is likely to be *very* slow.

The question is whether a Python implementation for .NET would be CLS
compliant (CLS == Common Language Specification). The existing
implementation has shown that this is not possible without giving up
parts of the Python semantics.

I am a new python tinkerer. I love the language. But what is its
future but as a legacy tool?


No. Instead, most .NET users will find out that .NET is *not* a
juggernaut, but restricted to C#, in practice. So Python might even
survive .NET :-)

That said: If you think the Python-.NET story should be a better one,
feel free to contribute. Python is a volunteer effort, and without
volunteers, there will be no progress. Before starting, please have a
look at the excellent Python-for-.NET, which uses the native-code
Python implementation to host .NET, giving Python programs full access
to the framework.

Regards,
Martin
Jul 18 '05 #2
Allenabethea wrote:
I am a new python tinkerer. I love the language. But what is its future but as a legacy tool?

allen


As far as I've learned so far, .net is good for client server but not
that great for standalone because of the need for the .net runtime to
run things, which creates a large overhead. Performance is an issue too,
as everything compiles JIT. I think that's why although .net is a great
idea, a lot of languages will remain language of choice for
standalone/no runtimes/speed critical/cross platform aplications. I
could be wrong, but I don't think I'm far from the truth.

Gustavo Campanelli
Jul 18 '05 #3
al**********@aol.com (Allenabethea) writes:

I am a new python tinkerer. I love the language. But what is its
future but as a legacy tool?


What, has .NET suddenly turned out to be popular while I wasn't
watching? The whole world is hardly jumping on the .NET platform,
actually mostly people seem to be ignoring it...

Or is this a troll of some kind?

You might also want to take a look at:

http://zope.org/Members/Brian/PythonNet/

--
Ville Vainio http://www.students.tut.fi/~vainio24
Jul 18 '05 #4
In article <m3************@mira.informatik.hu-berlin.de>,
Martin v. Löwis <ma****@v.loewis.de> wrote:
Jul 18 '05 #5
Ville Vainio wrote:
What, has .NET suddenly turned out to be popular while I wasn't
watching?


Where I work, .NET is pretty popular. People are fascinated of
introspection/reflection, (relative) platform-independence,
ubiquitous serialization, powerful development tools, and the
back-up of a large company.

Of course, they all use C#, and consider the other .NET languages
toys.

Regards,
Martin

Jul 18 '05 #6
ma****@v.loewis.de (Martin v. =?iso-8859-15?q?L=F6wis?=) wrote in
news:m3************@mira.informatik.hu-berlin.de:
As for generating MSIL byte codes: This is also possible, and has been
demonstrated. It also has been demonstrated that an initial
implementation is likely to be *very* slow.

The question is whether a Python implementation for .NET would be CLS
compliant (CLS == Common Language Specification). The existing
implementation has shown that this is not possible without giving up
parts of the Python semantics.

The main problem is that functions are first class objects in Python, but
not in the CLS. The CLS uses delegates to refer to functions, and a
delegate encapsulates both an object and a pointer to a method.

The CLS does have pointers to methods, but the situations in which they can
be used are limited by the code validator: there are two MSIL code
sequences which may be used to construct delegates, one for static
methods, one for non-static, both involve pushing a function pointer onto
the stack and then calling the delegate constructor, but in neither case
can the function pointer come from a variable.

To model Python within the environment, you can use a delegate to refer to
a static function (the object reference is null in this case), or to refer
to a bound method, but you cannot easily create a delegate to refer to an
unbound method. This makes any Python code using classes extremely hard to
model.

The original attempt at porting Python to this environment used the
reflection classes to get around this. Using reflection you can get objects
which indirectly reference classes and their methods, you can then create a
delegate from a System.Reflection.MethodInfo object at the point where the
unbound method becomes a bound method. Unfortunately, creating a delegate
from a MethodInfo is a couple of hundred times slower than creating a
delegate from a pointer to a method.

It is even possible to get a pointer to a method and then create a delegate
from it entirely within the constraints applied by the code validator, but
again this uses the Reflection classes and is at least as slow as using the
MethodInfo object.

I have been playing around with a variant on the managed Python compiler,
and I think I have figured a way to implement Python which might just get
around this bottleneck. Unfortunately it requires a lot of refactoring from
the original model, and I'm only working on it occasionally in my spare
time. Basically the idea is to compile static wrapper functions for every
method (at runtime). Obviously this is slow, but at least you only take the
hit once per class. Every unbound method, or bound method can keep a
delegate to the static wrapper, and we lose the overhead of the reflection
classes. Wrapper functions can also wrap constructors.

So far most of my refactoring has been concentrating on replacing the
original runtime with one based on a class hierarchy and modelling some of
the more recent Python behaviour. This simplifies and also speeds up the
code somewhat, although I think I have just about reached the limits I can
achieve before I do the function wrappers.

--
Duncan Booth du****@rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
Jul 18 '05 #7
"Martin v. Löwis" <ma****@v.loewis.de> writes:
Ville Vainio wrote:
What, has .NET suddenly turned out to be popular while I wasn't
watching?
Where I work, .NET is pretty popular. People are fascinated of
introspection/reflection, (relative) platform-independence,
ubiquitous serialization, powerful development tools,


....
and the back-up of a large company.


Oh :-)

More sponsorship for the PSF, please!

Cheers,
mwh

--
I have a feeling that any simple problem can be made arbitrarily
difficult by imposing a suitably heavy administrative process
around the development. -- Joe Armstrong, comp.lang.functional
Jul 18 '05 #8

"Duncan Booth" <du****@NOSPAMrcp.co.uk> wrote in message
news:Xn***************************@127.0.0.1...
The question is whether a Python implementation for .NET would be CLS
compliant (CLS == Common Language Specification). The existing
implementation has shown that this is not possible without giving up
parts of the Python semantics.
The main problem is that functions are first class objects in Python, but
not in the CLS.


Thank you for this and the persuant explanation. I had been wondering
whether a .NET subset would be sensible. Hah! The design principle of
'everything, including funtions, is a (first-class) object' is part of the
beauty and ease-of-use of Python. Demotion of functions would point toward
'calculator Python'.
The CLS uses delegates to refer to functions, and a
delegate encapsulates both an object and a pointer to a method. .... I have been playing around with a variant on the managed Python compiler,
and I think I have figured a way to implement Python which might just get
around this bottleneck.


Good luck. Not directly useful to me, but success can only promote the
usage of Python.

Terry J. Reedy
Jul 18 '05 #9
Duncan Booth <du****@NOSPAMrcp.co.uk> writes:
The question is whether a Python implementation for .NET would be CLS
compliant (CLS == Common Language Specification). The existing
implementation has shown that this is not possible without giving up
parts of the Python semantics.
The main problem is that functions are first class objects in Python, but
not in the CLS. The CLS uses delegates to refer to functions, and a
delegate encapsulates both an object and a pointer to a method.


In addition, I think one problem is that in CLS, a class has a
pre-determined set of data attributes, whereas in Python, instances
grow new data attributes as they live.
I have been playing around with a variant on the managed Python compiler,
and I think I have figured a way to implement Python which might just get
around this bottleneck. Unfortunately it requires a lot of refactoring from
the original model, and I'm only working on it occasionally in my spare
time.


Very interesting. Are you willing to share the intermediate results
that you get? Publish early, publish often :-)

Regards,
Martin
Jul 18 '05 #10
In article <4r********************@comcast.com>,
Terry Reedy <tj*****@udel.edu> wrote:
Jul 18 '05 #11
"Martin v. Löwis" <ma****@v.loewis.de> wrote in message news:<br*************@news.t-online.com>...
Ville Vainio wrote:
What, has .NET suddenly turned out to be popular while I wasn't
watching?


Where I work, .NET is pretty popular. People are fascinated of
introspection/reflection, (relative) platform-independence,
ubiquitous serialization, powerful development tools, and the
back-up of a large company.

Of course, they all use C#, and consider the other .NET languages
toys.

Regards,
Martin

only if you mean Windows 95, 98, ME, 2000, XP as "platform
independant"

..Net is and for all PRACTICAL PURPOSED be a WINDOWS ONLY development /
runtime environment.
Jul 18 '05 #12
ja*************@yahoo.com (Y2KYZFR1) writes:
only if you mean Windows 95, 98, ME, 2000, XP as "platform
independant"


People enjoy running .NET applications on OS X, through Rotor.

Regards,
Martin
Jul 18 '05 #13
Why is python incompatible with .net? Why can't python be coded in C#?


It's not. The .net virtual machine is Turing Complete.

C//

Jul 18 '05 #14
The main problem is that functions are first class objects in Python, but
not in the CLS.


Functions are only addresses in C, the (main) language Python is
implemented in.

C//

Jul 18 '05 #15
On Tue, 09 Dec 2003 03:24:48 GMT, Courageous wrote:
Why is python incompatible with .net? Why can't python be coded in C#?


It's not. The .net virtual machine is Turing Complete.


Sure, you could create and run a python interpreter on the .NET
runtime, but how is that better than running the C implementation?
Presumably people who discuss .NET integration are looking for the
sort of language-agnostic plug-and-play that .NET promises. This is a
different scenario than simply re-implementing python on a new
platform.

-D

--
Contrary to popular belief, Unix is user friendly.
It just happens to be selective about who it makes friends with.
-- Dave Parnas

www: http://dman13.dyndns.org/~dman/ jabber: dm**@dman13.dyndns.org
Jul 18 '05 #16
"Courageous" wrote:
The main problem is that functions are first class objects in Python, but
not in the CLS.


Functions are only addresses in C, the (main) language Python is
implemented in.


what parts of "The CLS does have pointers to methods, but the situations
in which they can be used are limited by the code validator" and "in neither
case can the function pointer come from a variable" did you have trouble
understanding?

</F>


Jul 18 '05 #17
ma****@v.loewis.de (Martin v. =?iso-8859-15?q?L=F6wis?=) wrote in
news:m3************@mira.informatik.hu-berlin.de:
The main problem is that functions are first class objects in Python,
but not in the CLS. The CLS uses delegates to refer to functions, and
a delegate encapsulates both an object and a pointer to a method.
In addition, I think one problem is that in CLS, a class has a
pre-determined set of data attributes, whereas in Python, instances
grow new data attributes as they live.


I don't believe that is too much of a problem. Even in Python many of the
data types have a fixed set of attributes. Even user defined classes, if
they use __slots__, might not allow you to add attributes.

So, for .Net, some user defined classes might have a __dict__ attribute,
but others don't. Attributes which are accessed through __dict__ won't be
visible to non-Python code, but that shouldn't be a problem.
I have been playing around with a variant on the managed Python
compiler, and I think I have figured a way to implement Python which
might just get around this bottleneck. Unfortunately it requires a
lot of refactoring from the original model, and I'm only working on
it occasionally in my spare time.


Very interesting. Are you willing to share the intermediate results
that you get? Publish early, publish often :-)

I'm more than willing to share, but so far its been a massive refactoring
job so I was waiting until things settled down a bit before releasing
anything. I expect the main speed gains to come when I get the new model
for functions and methods working and eliminate as far as possible calls
the reflection apis.
--
Duncan Booth du****@rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
Jul 18 '05 #18
ma****@v.loewis.de (Martin v. Löwis) writes:
al**********@aol.com (Allenabethea) writes:
Why is python incompatible with .net? Why can't python be coded in
C#?
Who says that it cannot be coded in C#. It is a matter of fact that it
currently isn't, but it would be possible to reimplement the Python
interpreter in C# (instead of implementing it in C).

As for generating MSIL byte codes: This is also possible, and has been
demonstrated. It also has been demonstrated that an initial
implementation is likely to be *very* slow.


http://www.python.org/~jeremy/weblog/

"""Jim Hugunin is at it again""":

http://primates.ximian.com/~miguel/ironpython

"""I've been working off and on for the past couple of months on a new
implementation of Python for the CLR called IronPython. It compiles Python
programs into verifiable IL and then dynamically executes them."""

Interestingly, many of the (micro-) benchmarks show that IronPython is
*faster* than Python 2.3.

The question is whether a Python implementation for .NET would be CLS
compliant (CLS == Common Language Specification). The existing
implementation has shown that this is not possible without giving up
parts of the Python semantics.

[...]

Still true, I guess.
John
Jul 18 '05 #19
> >Why is python incompatible with .net? Why can't python be coded in C#?

It's not. The .net virtual machine is Turing Complete.


The subject here is imprecise. The issue is that .net performs very poorly with
dynamic languages. So, for example, Microsoft is adding static features to
JScript in an attempt to improve its performance.

..net is having a homogenizing effect on programming languages. In the end, they
may all become the same. And the ultimate .net language will not be Python.

Jul 18 '05 #20
what parts of "The CLS does have pointers to methods, but the situations
in which they can be used are limited by the code validator" and "in neither
case can the function pointer come from a variable" did you have trouble
understanding?


Probably most of it. I was tired. :)

C//

Jul 18 '05 #21
It's not. The .net virtual machine is Turing Complete.


The subject here is imprecise. The issue is that .net performs very poorly with
dynamic languages.


Yes, I agree. While it would be *possible* to implement most anything
on .net, any language that isn't a close friend, thematically, to C#,
really isn't at home there. The underlying framework is really a virtual
machine designed to implement C#'s features.

Moreover, and more to the point, any other programming language which
does not use these primitives as intended (e.g., uses dynamic composition
to achieve inheritance instead of the framework's primary primitives to
achieve same) will be a second bastard child in the environment, with
glaring warts that will be obvious the moment interoperation is attempted.

Since the *main appeal* of .net is language interop, ...

Well, perhaps that answers the OP's question.

C//

Jul 18 '05 #22
Gustavo Campanelli <bi************@SPAMciudad.FILTERcom.ar> wrote:

As far as I've learned so far, .net is good for client server but not
that great for standalone because of the need for the .net runtime to
run things, which creates a large overhead.
Disk space is cheap and getting cheaper. Overhead is just not the issue it
once was. Plus, the run-time only has to be installed once, and it will be
included in all future Microsoft operating systems.
Performance is an issue too, as everything compiles JIT.
This is less of an issue than you might think. As you say, everything is
compiled the first time it is encountered, so anything used more than one
is actually native code. I'm also dubious, but people I respect tell me
that .NET program performance is surprisingly good.

Plus, the standard library is quite outstanding. It rivals Python's, and
exceeds it in Microsoft-centric areas.
I think that's why although .net is a great
idea, a lot of languages will remain language of choice for
standalone/no runtimes/speed critical/cross platform aplications. I
could be wrong, but I don't think I'm far from the truth.


There are rumors that the Windows release after Longhorn might be
restricted to CLR/.NET programs only. I don't know what that actually
means, nor what the sentencing guidelines are for violating the rule, but
there it is.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 18 '05 #23
Allenabethea wrote:
Jython is 100% java coded python.
Python objects work with javacompilers and Virtual machines.

I am a hobby programmer so the technical reasons are probably beyond me...
Why is python incompatible with .net? Why can't python be coded in C#?

I see the the MONO project on linux/unix is advancing. .Net seems to be a
juggernaut especially if programmers will be able to use their favorite(most
productive) language to program in. (every language but python)

I am a new python tinkerer. I love the language. But what is its future but
as a legacy tool?

allen


Some who I suspect know a thing or two about python and .NET seem to disagree:

http://primates.ximian.com/~miguel/activity-log.php

Cheers,

f
Jul 18 '05 #24

"Fernando Perez" <fp*******@yahoo.com> wrote in message
news:br**********@peabody.colorado.edu...
Allenabethea wrote:
Jython is 100% java coded python.
Python objects work with javacompilers and Virtual machines.

I am a hobby programmer so the technical reasons are probably beyond me... Why is python incompatible with .net? Why can't python be coded in C#?

I see the the MONO project on linux/unix is advancing. .Net seems to be a juggernaut especially if programmers will be able to use their favorite(most productive) language to program in. (every language but python)

I am a new python tinkerer. I love the language. But what is its future but as a legacy tool?

allen
Some who I suspect know a thing or two about python and .NET seem to

disagree:
http://primates.ximian.com/~miguel/activity-log.php
This is real good news, but the fact that it's only at 0.1 makes me
suspect that they might find some real issues later that will slow
things down. But then, I'm old and cynical.

John Roth
Cheers,

f

Jul 18 '05 #25
John Roth wrote:
Some who I suspect know a thing or two about python and .NET seem to
disagree:

http://primates.ximian.com/~miguel/activity-log.php

Read only that
http://primates.ximian.com/~miguel/a...03/Dec-09.html
This is real good news, but the fact that it's only at 0.1 makes me
suspect that they might find some real issues later that will slow
things down. But then, I'm old and cynical. From that benchmark I conclude Iron shall be compared with psyco,

not CPython.

Mike


Jul 18 '05 #26

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
1
by: Tim Bradshaw | last post by:
I'd like to be able to install python with stow, and then to install various modules which use distutils, also with stow. This currently pretty much won't work, because Python chases symlinks to...
12
by: adamurbas | last post by:
ya so im pretty much a newb to this whole python thing... its pretty cool but i just started today and im already having trouble. i started to use a tutorial that i found somewhere and i followed...
206
by: WaterWalk | last post by:
I've just read an article "Building Robust System" by Gerald Jay Sussman. The article is here: http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf In it there is a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.