Is python very slow compared to C

C

Cameron Laird

.
.
.
You are right, we all know that, but I think the person who asked this
question doesn't want to hear a sales pitch. He asked a very specific
question regarding execution speed.

Also, a couple of people have written, "If you want speed, choose
assembler." With full recognition of all these comments, my spe-
cific response to the question regarding execution speed is, "If
you want speed, Python makes a great choice. We have re-coded
*from* C to Python in order to IMPROVE performance."

Python-coded applications aren't always faster than corresponding
C-coded ones. Sometimes they're considerably slower. Many new-
comers to Python, though, underestimate how much performance they'll
gain *algorithmically* by developing at the high level of Python or
Erlang or ML.
 
S

Steven D'Aprano

What is the disavantage of Lua comparing with Python ? Or Ocaml
comparing with Python ?

If your developer gets hit by a bus, you won't easily find a replacement.
This may not be a factor if you are programming for pleasure, but in the
commercial world of software development, availability of skilled
programmers is absolutely critical for the use of a language.

I realise that neither Lua nor Ocaml are entirely unknowns, both have been
used commercially, but I believe Python developers are more widely
available.

Google "python programming": 19,000,000 hits.
Google "lua programming": 574,000 hits.
Google "ocaml programming": 325,000 hits.

That will give you a rough estimate for the amount of resources out there
on the web for each language. By comparison, even Forth gives 13 million
plus hits, and who uses Forth?

Another rough measure of the availability of resources is the Dummies test:

Google "python for dummies": 323,000 hits.
Google "lua for dummies": 46,400 hits.
Google "ocaml for dummies": 693 hits.

Only Python For Dummies is an actual dead-tree book. I think it is safe to
conclude that Lua and Ocaml offer far fewer resources for somebody looking
to learn the language than does Python.

Lua appears to be *too* lightweight, without even classes or inheritance,
and a single data type where Python has dicts, sets, tuples and lists.

Ocaml seems to use more punctuation than I'm comfortable with (lots of
double semi-colons and -> symbols), but Python seems to be moving along
those lines too with list and generator comprehensions, and none of us
really want to return to Cobol's verbose arithmetic.

Wikipedia says "However, [Ocaml] also forces the programmer to conform to
the constraints of the type system, which can require careful thought and
close attention. ... effective use of OCaml's type system can require some
sophistication on the part of the programmer." That suggests that writing
Ocaml code may be more difficult than writing Python code. Wikipedia also
emphasises how hard it is for the compiler to generate good quality
machine code from Ocaml, which suggests that perhaps the compilation stage
could be slow.
 
B

bonono

Steven said:
Lua appears to be *too* lightweight, without even classes or inheritance,
and a single data type where Python has dicts, sets, tuples and lists.
I believe Lua does have features to implement class/inheritance.

As for the distinction of dict/set/tuple/list or one single table data
type(which can be used as either dict or list and implemented as set,
not sure about tuple), it is up to debate.

Though I have mentioned in another post that the batteries in Python is
extremely appealing to solve real world problems as no matter how good
a language can be, re-implementing something from scratch is always a
pain(and error prone).
 
D

diffuser78

Thnaks everybody for their comments. I am an average programmer in C
and wanted to make a hop to python and was just trying to clear my mind
with the confusions. Bit I guess I will go ahead and spend some time
with python and do my next project in python.


thanks for the feedback
 
P

PA

availability of skilled programmers is absolutely critical for the use
of a language.

By that measure, we should all be using Java, no?

"TIOBE Programming Community Index"
http://www.tiobe.com/tpci.htm
By comparison, even Forth gives 13 million plus hits, and who uses
Forth?

Anyone writing in English:

http://www.answers.com/forth&r=67
Lua appears to be *too* lightweight, without even classes or
inheritance,

Programming in Lua
Object-Oriented Programming
http://www.lua.org/pil/16.html
and a single data type where Python has dicts, sets, tuples and lists.

"Lua gives you the power; you build the mechanisms."
-- Roberto Ierusalimschy, "Programming in Lua", December 2003
http://www.lua.org/pil/12.1.2.html

Cheers
 
C

Cameron Laird

.
.
.
on the web for each language. By comparison, even Forth gives 13 million
plus hits, and who uses Forth?
.
.
.
The programmers of, among other things, the FedEx bar-code reader,
the Sun boot loader, and parts of the Space Shuttle.
 
S

Steven D'Aprano

By that measure, we should all be using Java, no?

I said nothing about whether Lua or Ocaml were good languages to take up
if you want to learn a programming language. In fact, it follows from
simple economics that individual developers should avoid languages that
are too popular. No matter how good you are as a Visual Basic programmer,
the price you can command will be pushed downwards by competition with
millions of other VB programmers.

I was talking about the other side of the equation. If you are hiring
developers to work for you, it is absolutely critical that there is no
shortage of skillful programmers in the language(s) you use. "No shortage"
doesn't mean "only use Java" -- there are disadvantages to Java that
outweigh the fact that there is no shortage of developers.

"TIOBE Programming Community Index"
http://www.tiobe.com/tpci.htm


Anyone writing in English:

http://www.answers.com/forth&r=67

Which might be relevant if I searched for "forth", but I didn't. I googled
on "forth programming". Yes, there will be some false positives, but I
never claimed that this was anything more than a rough and imprecise
estimate of the availability of resources for the languages.

Programming in Lua
Object-Oriented Programming
http://www.lua.org/pil/16.html

Did you actually bother to read the page you linked to? It describes how
you can emulate object-like behaviour for Lua tables. The following page
is even more explicit: "Lua does not have the concept of class".

That means that the object-oriented framework, which you get for free in
Python, has to be at least partially handled by the programmer in Lua.
Perhaps Lua makes it easy to do, but it is still something that doesn't
need to be done in Python because it is already there.

"Lua gives you the power; you build the mechanisms."
-- Roberto Ierusalimschy, "Programming in Lua", December 2003
http://www.lua.org/pil/12.1.2.html

Which is fine, but the more mechanisms you have to build, the longer it
will take you to actually get to the important work, which is putting it
all together to create your application.
 
S

Steven D'Aprano

.
.
.
.
.
.
The programmers of, among other things, the FedEx bar-code reader,
the Sun boot loader, and parts of the Space Shuttle.


Okay, so that's three... *wink*

You missed Apple's boot loader.

I love Forth. I'm no good at thinking at that low count-the-bytes level,
but if I was, I'd much prefer to use Forth than C or assembly. I've got a
bunch of Forth books here, and when I'm bored I read them for
entertainment, and dream. I love the fact that Forth is still in use. But
I'm under no illusions that there are millions of Forth developers getting
paid to write in Forth.
 
R

Roy Smith

Steven D'Aprano said:
I love Forth. I'm no good at thinking at that low count-the-bytes level,
but if I was, I'd much prefer to use Forth than C or assembly. I've got a
bunch of Forth books here, and when I'm bored I read them for
entertainment, and dream. I love the fact that Forth is still in use. But
I'm under no illusions that there are millions of Forth developers getting
paid to write in Forth.

If you like Forth, take a look at PostScript. Most people think of
PostScript as a print file format and don't realize it's a real programming
language. Variables, functions, loops, if statements, and all that good
stuff. The syntax is very Forth-like.
 
M

Michael Tobis

Read his post again. He didn't ask a specific question at all, and he certainly didn't mention execution speed.

agreed
He asked a vague, meaningless question about whether Python was "slow compared to C".

No, that is both wrong and gratuitously harsh. He had heard vague
meaningless complaints about whether Python was "slow compared to C"
and asked us to "pinpoint the issue", i.e., to determine in what sense
the allegation might be true. That is a precise and meaningful question
and being asked in a commendable fashion.

mt
 
M

malv

That's why Microsoft is bringing IronPython on board to have something
more decent available with .NET
 
D

Dennis Lee Bieber

That will give you a rough estimate for the amount of resources out there
on the web for each language. By comparison, even Forth gives 13 million
plus hits, and who uses Forth?
A lot of the folks maintaining various MUCKs (especially those based
on the FuzzBall server)... MUF => Multi-User Forth, is the environment
development language. I never got into MUCKing enough to request/earn a
MUF-bit in my profile, which meant I was limited to MPI (a LISP-like
language that didn't have direct access to the byte level; an erroneous
MUF program could crash the MUCK, MPI scripts couldn't).
--
 
D

Daniel Ciesinger

13m hits for forth as in "set forth", "firth of forth" etc.
..
You missed Apple's boot loader.

And LOTs of small tools, scripts, analyzers written in Forth, because it
has such a nice "evaluate", beating e.g. JavaScript "evaluate" by a
speed advantage around 1000 or more...
You can feed that with a datastream such as

123.50 MONITOR Rx 03 DC 0A 0D
124.00 COMMS Tx 01 A5

....and convert such stuff into XML, SVG or any representation you like.
Very useful (and fast) e.g. for automotive applications.
I love Forth. I'm no good at thinking at that low count-the-bytes level,
but if I was, I'd much prefer to use Forth than C or assembly. I've got a
bunch of Forth books here, and when I'm bored I read them for
entertainment, and dream. I love the fact that Forth is still in use. But
I'm under no illusions that there are millions of Forth developers getting
paid to write in Forth.

Maybe a few hundred - and then some thousands who write their utils in
Forth during their paid time...

Daniel
 
B

bonono

Steven said:
Did you actually bother to read the page you linked to? It describes how
you can emulate object-like behaviour for Lua tables. The following page
is even more explicit: "Lua does not have the concept of class".

That means that the object-oriented framework, which you get for free in
Python, has to be at least partially handled by the programmer in Lua.
Perhaps Lua makes it easy to do, but it is still something that doesn't
need to be done in Python because it is already there.

Lua does not have a concept of class doesn't mean it doesn't have the
concept/framework of OO. It seems to be using a prototype based OO
framework similar to javascript. So one can have features like
inheritance without "class".

I can speak the same about Python if I view it from a prototype based
perspective, where one get them for free in Lua but need to implement
them in Python.
 
E

Elizabeth D Rather

Cameron Laird said:
.
.
.
.
.
.
The programmers of, among other things, the FedEx bar-code reader,
the Sun boot loader, and parts of the Space Shuttle.

We have several thousand customers, although we don't hear from them enough
to know how active they are. Most of them are doing embedded systems (such
as the FedEx package tracker), although there are also quite a few doing
Windows apps.

A lot of our embedded work is for aerospace and government customers, plus a
number in the private sector. All the DirecTV uplink antennas are
controlled by one of our systems made by VertexRSI,
http://www.tripointglobal.com/vertexrsi.html. Another really neat customer
is Sunrise Systems, http://www.sunrisesystems.com/index.htm. They make
moving displays, and are working on one for one of the rebuilt World Trade
Center bldgs, one to be installed in Switzerland next month, and something
for Disney World.

Open Firmware has already been mentioned, and I should add that IBM's
high-end servers also use it. I teach Forth courses there once or twice a
year, and have trained a couple hundred engineers in IBM alone.

You can get more info on our web site www.forth.com, including a link to a
paper presenting a history of Forth.

Cheers,
Elizabeth

--
==================================================
Elizabeth D. Rather (US & Canada) 800-55-FORTH
FORTH Inc. +1 310-491-3356
5155 W. Rosecrans Ave. #1018 Fax: +1 310-978-9454
Hawthorne, CA 90250
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==================================================
 
S

Steven D'Aprano

I can speak the same about Python if I view it from a prototype based
perspective, where one get them for free in Lua but need to implement
them in Python.

Sure. And if you need prototypes, then all else being
equal that would be a disadvantage of Python compared
to Lua.

On the other hand, I'd suggest that far more
programmers are familiar with classes than prototypes,
regardless of any objective advantages or disadvantages
of one over the other. Perhaps that's one of the
reasons why Lua is lacking the market penetration of
Python: programmers may look at it and say "No classes?
Prototyping? WTF is that? I don't have time to learn
something so different, better stick to languages which
have a smaller learning curve."
 
S

Steve Holden

Steven said:
Sure. And if you need prototypes, then all else being
equal that would be a disadvantage of Python compared
to Lua.

On the other hand, I'd suggest that far more
programmers are familiar with classes than prototypes,
regardless of any objective advantages or disadvantages
of one over the other. Perhaps that's one of the
reasons why Lua is lacking the market penetration of
Python: programmers may look at it and say "No classes?
Prototyping? WTF is that? I don't have time to learn
something so different, better stick to languages which
have a smaller learning curve."
Or perhaps they'll see that Self demonstrated the advantages and
disadvantages of the prototyping approach long ago.

regards
Steve
 
B

bonono

Steven said:
Sure. And if you need prototypes, then all else being
equal that would be a disadvantage of Python compared
to Lua.

On the other hand, I'd suggest that far more
programmers are familiar with classes than prototypes,
regardless of any objective advantages or disadvantages
of one over the other. Perhaps that's one of the
reasons why Lua is lacking the market penetration of
Python: programmers may look at it and say "No classes?
Prototyping? WTF is that? I don't have time to learn
something so different, better stick to languages which
have a smaller learning curve."

The "=" operator in Python is also quite different from many language
people had experience like C or VB etc. And using the same argument,
everyone may still be programming in COBOL now.

And if we use market penetration as measure, Perl seems to be easier
for people ?
 

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

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,278
Latest member
BuzzDefenderpro

Latest Threads

Top