473,809 Members | 2,804 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2149
al**********@ao l.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**********@ao l.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.informati k.hu-berlin.de>,
Martin v. Löwis <ma****@v.loewi s.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.infor matik.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.Reflecti on.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.u k
int month(char *p){return(1248 64/((p[0]+p[1]-p[2]&0x1f)+1)%12 )["\5\x8\3"
"\6\7\xb\1\x9\x a\2\0\4"];} // Who said my code was obscure?
Jul 18 '05 #7
"Martin v. Löwis" <ma****@v.loewi s.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.funct ional
Jul 18 '05 #8

"Duncan Booth" <du****@NOSPAMr cp.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****@NOSPAMr cp.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

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

Similar topics

220
19205
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 any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
1
2011
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 set sys.prefix, which means that the site path gets set to the `true' location rather than the one with all the links. This means that Python won't find modules you install with stow, unless you glue the linky site directory into sys.path. Doing...
12
3021
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 the instructions and couldnt get the correct results. heres the code stuff... temperature=input("what is the temperature of the spam?") if temperature>50: print "the salad is properly cooked." else:
206
8396
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 footprint which says: "Indeed, one often hears arguments against building exibility into an engineered sys- tem. For example, in the philosophy of the computer language Python it is claimed: \There should be one|and preferably only one|obvious...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10391
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9200
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4333
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3862
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.