What python can NOT do?

Q

qwe rty

i know that an interpreted language like python can't be used to make
an operating system or system drivers.

what else can NOT be done in python? what are the limitations of the
language?
 
R

r

what else can NOT be done in python? what are the limitations of the
language?

Why would you even want to know what can't be done? What is it that
you would like to do with Python? If you want a one size fits all
language you may be looking for a very long time...
 
T

Tim Chase

qwe said:
i know that an interpreted language like python can't be used to make
an operating system or system drivers.

As long as you are willing to write the OS hooks in C, you can
write the userspace device drivers in Python:

https://www.linuxquestions.org/ques...-driver-program-using-python-in-linux-687277/

Since Python is Turing-complete, there's no reason a whole OS
couldn't be authored in Python.
what else can NOT be done in python? what are the limitations of the
language?

I understand there's a little trouble getting Python to prove
that P=NP You'll also find that it only comes close to solving
the unrestricted three-body problem and the Traveling Salesman
problem is still limited to fallible heuristics and searching the
entire solution set in better than O(2**n) time.

-tkc
 
T

Tim Chase

what else can NOT be done in python? what are the limitations of the
I understand there's a little trouble getting Python to prove
that P=NP You'll also find that it only comes close to solving
the unrestricted three-body problem and the Traveling Salesman
problem is still limited to fallible heuristics and searching the
entire solution set in better than O(2**n) time.

I forgot about solving the Spam problem entirely. And answering
poorly worded/thought-out questions on the internet...

I've also been sorely disappointed by Python's ability to make a
good chocolate cream silk pie.

-tkc
 
Q

qwe rty

I forgot about solving the Spam problem entirely.  And answering
poorly worded/thought-out questions on the internet...

I've also been sorely disappointed by Python's ability to make a
good chocolate cream silk pie.

-tkc

if you don't know the answer please don't reply
 
R

r

Since Python is Turing-complete, there's no reason a whole OS
couldn't be authored in Python.

Yes, and one could go from NY to LA on a unicycle but would one really
want to? Talk about some redass and blueballs! *yikes*

Yes, if i have learned anything in my life, i can say there are
absolutely no boundaries to what humans can achieve short the limit of
their own imagination and the ever fading remainder of ones life.
 
S

Steven D'Aprano

i know that an interpreted language like python

Languages are neither interpreted nor compiled. *Implementations* are
interpreted or compiled.

Perl has only one implementation, which is interpreted (as far as I
know); Java has a number of implementations, some of which compile to
byte-code, some compile to machine-code. There are C interpreters as well
as C compilers. And languages like Forth have an unusual programming
model which doesn't easily match the conventional interpreted/compiled
distinction.

Python has a number of implementations, all of which are compiled to byte-
code, like early Java. None are purely interpreted; none are compiled to
machine-code, although there are add-ons to CPython which will compile
most Python code to machine-code. Some day, Python may include
implementations which compile directly to machine-code.

can't be used to make an operating system or system drivers.

With existing Python implementations, it would be difficult to write an
OS, because the implementations assume there is already an operating
system available to handle things like memory and disk IO. So before you
could write an OS in Python, you would need to write a new Python
implementation. However, you could easily write a "virtual OS" in Python
which sat on top of the regular OS.

Device drivers would be less difficult, but performance may be slow
compared to drivers written in (say) C.

Boot loaders are another type of software which would be impractical to
write in existing Python implementations.

what else can NOT be done in python? what are the limitations of the
language?

As a language, Python has no theoretical limits -- it is Turing Complete,
which means anything you can do in C, Java, Lisp, or any other Turing
Complete language, you could do in Python -- with sufficient effort, and
provided you don't care about efficiency.

In practice, though, we *do* care about efficiency, and about the effort
required to write the program in the first case. In practical terms,
Python the language makes most things easy to write but slower to run, so
there are very few applications which couldn't be written in Python.

A few things are more difficult than others. One of the hardest things to
do is to "sandbox" some arbitrary Python code from an untrusted source
and execute it in a restricted environment.

In practical terms, Python will let you write nearly any sort of program
you want, provided absolute performance isn't your provided. (To put it
another way, Python code is rarely "the fastest", but it is usually "fast
enough".) If performance is too slow, Python is an excellent "glue"
language, letting you write the bulk of your program in Python for ease,
the performance-critical parts in C for speed.

Some practical restrictions... if you are writing a web app, some hosting
providers don't provide access to Python on their webserver, so you're
limited to using whatever languages they provide, or finding another
provider.

All existing Python implementations require a minimum amount of memory to
operate. This is relatively high, so you probably couldn't use Python on
a device where you only had (say) 64K of memory. There's no Python
implementation for your ancient Mac Plus or Commodore 64, and there
probably never will be. Python the language is based on an execution
model with relatively high overhead, so even if you wrote an
implementation for such ancient machines, you probably couldn't do much
with it.

Existing Python implementations don't give you direct access to hardware,
and bit-manipulation has a lot of overhead in Python. Numerical
calculations (e.g. scientific array calculations) also suffer from
overhead, which is barely noticeable if you're doing a few thousand
calculations, but if you're doing a few tens of millions may be a little
slow. For these, you should use Python as an interface to numeric
libraries written in C, like Scipy and Numpy.
 
B

Bruce C. Baker

qwe rty said:
i know that an interpreted language like python can't be used to make
an operating system or system drivers.

what else can NOT be done in python? what are the limitations of the
language?

It's a floor wax and a dessert topping too! :)
 
T

Tim Chase

qwe said:
if you don't know the answer please don't reply

I'm not sure you understand -- Being a Turing complete language,
anything you can do in any other language, you can do in Python.
As "r" observed, it might not be a pleasant experience (though
there are a lot of things I'd rather do in Python than in C or
Assembly) but certainly doable.

So clearly the issue resides in your nonsensical question. You
asked for things you can't do with Python so I listed some. The
things you can't do in Python are things you can't do in any
other language either. To turn your snark on end, "If you can't
post a sensible question, please don't post in the first place".

But this is usenet, and Python can't solve the problem of
nonsensical questions posted on usenet. :-/

-tkc
 
N

Nobody

Yes, and one could go from NY to LA on a unicycle but would one really
want to? Talk about some redass and blueballs! *yikes*

Yes, if i have learned anything in my life, i can say there are
absolutely no boundaries to what humans can achieve short the limit of
their own imagination and the ever fading remainder of ones life.

Well, other than writing a program to determine whether a program in a
Turing-complete language will terminate on some input, or devising a
formal system which is sound, complete, and able to express its own
metatheory, or ...

Some things are actually impossible.
 
Q

qwe rty

I'm not sure you understand -- Being a Turing complete language,
anything you can do in any other language, you can do in Python.
  As "r" observed, it might not be a pleasant experience (though
there are a lot of things I'd rather do in Python than in C or
Assembly) but certainly doable.

So clearly the issue resides in your nonsensical question.  You
asked for things you can't do with Python so I listed some.  The
things you can't do in Python are things you can't do in any
other language either.  To turn your snark on end, "If you can't
post a sensible question, please don't post in the first place".

But this is usenet, and Python can't solve the problem of
nonsensical questions posted on usenet. :-/

-tkc

i am free to post , you are free to ignore
 
Q

qwe rty

Languages are neither interpreted nor compiled. *Implementations* are
interpreted or compiled.

Perl has only one implementation, which is interpreted (as far as I
know); Java has a number of implementations, some of which compile to
byte-code, some compile to machine-code. There are C interpreters as well
as C compilers. And languages like Forth have an unusual programming
model which doesn't easily match the conventional interpreted/compiled
distinction.

Python has a number of implementations, all of which are compiled to byte-
code, like early Java. None are purely interpreted; none are compiled to
machine-code, although there are add-ons to CPython which will compile
most Python code to machine-code. Some day, Python may include
implementations which compile directly to machine-code.


With existing Python implementations, it would be difficult to write an
OS, because the implementations assume there is already an operating
system available to handle things like memory and disk IO. So before you
could write an OS in Python, you would need to write a new Python
implementation. However, you could easily write a "virtual OS" in Python
which sat on top of the regular OS.

Device drivers would be less difficult, but performance may be slow
compared to drivers written in (say) C.

Boot loaders are another type of software which would be impractical to
write in existing Python implementations.


As a language, Python has no theoretical limits -- it is Turing Complete,
which means anything you can do in C, Java, Lisp, or any other Turing
Complete language, you could do in Python -- with sufficient effort, and
provided you don't care about efficiency.

In practice, though, we *do* care about efficiency, and about the effort
required to write the program in the first case. In practical terms,
Python the language makes most things easy to write but slower to run, so
there are very few applications which couldn't be written in Python.

A few things are more difficult than others. One of the hardest things to
do is to "sandbox" some arbitrary Python code from an untrusted source
and execute it in a restricted environment.

In practical terms, Python will let you write nearly any sort of program
you want, provided absolute performance isn't your provided. (To put it
another way, Python code is rarely "the fastest", but it is usually "fast
enough".) If performance is too slow, Python is an excellent "glue"
language, letting you write the bulk of your program in Python for ease,
the performance-critical parts in C for speed.

Some practical restrictions... if you are writing a web app, some hosting
providers don't provide access to Python on their webserver, so you're
limited to using whatever languages they provide, or finding another
provider.

All existing Python implementations require a minimum amount of memory to
operate. This is relatively high, so you probably couldn't use Python on
a device where you only had (say) 64K of memory. There's no Python
implementation for your ancient Mac Plus or Commodore 64, and there
probably never will be. Python the language is based on an execution
model with relatively high overhead, so even if you wrote an
implementation for such ancient machines, you probably couldn't do much
with it.

Existing Python implementations don't give you direct access to hardware,
and bit-manipulation has a lot of overhead in Python. Numerical
calculations (e.g. scientific array calculations) also suffer from
overhead, which is barely noticeable if you're doing a few thousand
calculations, but if you're doing a few tens of millions may be a little
slow. For these, you should use Python as an interface to numeric
libraries written in C, like Scipy and Numpy.

thank you very much ,THIS is the sort of answer i wanted
 
T

Tomasz Rola

i know that an interpreted language like python can't be used to make
an operating system or system drivers.

what else can NOT be done in python? what are the limitations of the
language?

Oh, my. And now everybody points at you this Turing-completeness. The
issue, in my opinion, is not that something cannot be done. The truth
about Turing-completeness is, I would say, you can do whatever but
sometimes you will not because it would be too ugly. My private list of
things that when implemented in Python would be ugly to the point of
calling it difficult:

1. AMB operator - my very favourite. In one sentence, either language
allows one to do it easily or one would not want to do it (in an ugly
way).

http://www.randomhacks.net/articles/2005/10/11/amb-operator

After quite some googling I was finally able to locate sample
implementation, but I cannot say ATM how well it works and if it is
practical enough to use it in any of my programs. If time permits, I will
try it, hopefully.

http://www.c2.com/cgi/wiki?AmbInPython

2. Changing the language from the inside.

Everybody can change the interpreter, right? But how about doing some
bigger, maybe even fundamental change to the language by means offered by
the language itself?

Example:

If Python had no object system, or if I wanted to implement one in
different way (say, I would like to experiment or I would not want to wait
for a new release). In some languages that interest me now, it is possible
and practical, more or less. So it can sometimes backfire - what OO system
should I choose for my next Scheme program, etc. Because there are few of
them :), all (? - I believe) implemented as a code library. Just install
it and off you go, now you have OO programming. Actually, I don't use OO
all that much recently (maybe I feel disapointed a bit, or something).

Also, I have read (but not checked it myself) that for some time Common
Lisp had it's now-official CLOS distributed and tested in a form of
library. Say, have they adopted OO with single inheritance as a part of CL
ANSI standard - I would still be able to have OO with multiple
inheritance. I would just have to download and install CLOS. No change to
interpreter or compiler. From their point of view, CLOS would be just
another library.

http://en.wikipedia.org/wiki/Common_Lisp_Object_System

Judging by this code, introducing OO to the language is relatively easy:

http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-14.html

It is not possible to alter Python in a minor way, I think. Something
simpler than OO, like a new keyword or structures:

http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-10.html
http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-11.html

Some readers could oppose the above by saying that Lisp's syntax is so
primitive that it can be used to implement just any programming paradigm,
so having it as a loadable code is not a big achievement. Well, it seems
to me that Python has even simpler syntax or on par with Lisp family,
so...

Some (perhaps other) readers could also say, that there is no need to
extend Python. It already has sets and "yield" and... But some time ago it
did not. As far as I can tell, it can be a bit too hard to go into
"experimenting mode" with Python. Something like adding "yield" all but
myself. It only takes few kilos of code for a working OO in another
language, so how hard could such "yield" be? Well, in Python I probably
wouldn't dare.

BTW I hope nobody's feeling have been hurt. This was meant to be
informative, not offensive.

BTW2. As I said, these are _possible_ things (Turing complete language,
and so on). But adding them would require some hard work and would produce
ugly and/or fragile code, so I decided it could be easier to learn another
language...

Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature. **
** As the answer, master did "rm -rif" on the programmer's home **
** directory. And then the C programmer became enlightened... **
** **
** Tomasz Rola mailto:[email protected] **
 
A

Aahz

i am free to post , you are free to ignore

Well -- don't you think the same applies in reverse? Remember that
Python is named after the comedy group Monty Python, and jokes are a
frequent occurrence on this group.
 
S

Steven D'Aprano

My private list of
things that when implemented in Python would be ugly to the point of
calling it difficult:

1. AMB operator - my very favourite. In one sentence, either language
allows one to do it easily or one would not want to do it (in an ugly
way).

http://www.randomhacks.net/articles/2005/10/11/amb-operator


Fascinating, but I don't exactly see how that's actually *useful*. It
strikes me of combining all the benefits of COME FROM with the potential
performance of Bogosort, but maybe I'm being harsh.

On the other hand, it sounds rather like Prolog-like declarative
programming. I fear that, like Prolog, it risks massive performance
degradation if you don't apply the constraints in the right order.


2. Changing the language from the inside.

Everybody can change the interpreter, right? But how about doing some
bigger, maybe even fundamental change to the language by means offered
by the language itself?

Like Forth. You need it in Forth, because it has a very sparse set of
language features, and everything is bootstrapped from a small set of
commands, so the ability to re-define the language as you go is (1)
necessary and (2) free.

But for Python, I don't know... it sounds cool, but in practice? It
sounds like the sort of thing that allows programmers to spend three
hours writing a new control structure which will save them three minutes.

And of course, for all but the tiniest, one-man-band applications,
readability is important. Sure, you've created a gee-whizz control
structure which combines try, while and if into one keyword, and it
automatically does logging and threading, fantastic. But how will anyone
else be able to maintain it when you're gone?

The ability to change the language is one step into a tarpit, where
everything is possible but nothing is easy, and where you spend all your
time writing language features and none of your time building the useful
functionality you actually want. It sounds like something you want in a
language you use for designing languages, rather than writing
applications.
 
H

Hendrik van Rooyen

I've also been sorely disappointed by Python's ability to make a
good chocolate cream silk pie.

This is not pythons fault - it is yours, for failing to collaborate with a
good hardware designer for the robotics.

- Hendrik
 
T

Tomasz Rola

what else can NOT be done in python? what are the limitations of the
language? [...]
I forgot about solving the Spam problem entirely.  And answering
poorly worded/thought-out questions on the internet...
I've also been sorely disappointed by Python's ability to make a
good chocolate cream silk pie.

if you don't know the answer please don't reply

If you want to ask a silly question don't ask it.

The question the OP asked was not silly.

Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature. **
** As the answer, master did "rm -rif" on the programmer's home **
** directory. And then the C programmer became enlightened... **
** **
** Tomasz Rola mailto:[email protected] **
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,197
Messages
2,571,040
Members
47,635
Latest member
SkyePurves

Latest Threads

Top