473,569 Members | 2,621 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is python very slow compared to C

I have just started to learn python. Some said that its slow. Can
somebody pin point the issue.

Thans

Feb 11 '06 #1
50 5673
di********@gmai l.com wrote:
I have just started to learn python. Some said that its slow. Can
somebody pin point the issue.


It depends on what you are doing. Much of Python is just wrapped C. So
many things are very fast.
Feb 11 '06 #2
Most languages are slow compared to "C". Python is fast enough for just
about anything you want to do with it.

Robert

Feb 11 '06 #3
Yes this language is very slow, but frequently this isn't a problem,
because you are using fast functions/libraries written in C, or you are
doing I/O bound operations. And Psyco, numeric/numarray, ShedSkin can
help in some other cases (Pyrex and other solutions allow you to mix in
lower level languages). If you are looking for pure algorithmic speed
you probably have to go look for other languages, like C, C++, Ocaml,
typed Lisp code, etc.

Bye,
bearophile

Feb 11 '06 #4
di********@gmai l.com wrote:
I have just started to learn python. Some said that its slow. Can
somebody pin point the issue.

Thans

"Some" doesn't know what he/she/they are talking about.
Generalizations like that upset me because it shows someone
that has some predisposition to some other language and they
don't want to be confused by "facts". Many "compiled
language" programmers fall into this category. Many times
you can write, debug, execute, and document a Python program
before "compiled language" guys can even get started. Many
believe that Python is also more maintainable over time.
When you come back to it in 6 months you will ACTUALLY BE ABLE
TO READ THE CODE. Productivity cannot be measured by
benchmarks alone.

Give Python a try and I'll bet you find that it is fast enough
(that's all that is important right) for all but device
drivers and highly scientific applications (and even then
there are solutions). The parts of Python that need to be
fast have been rewritten as binary libraries. That way you
get the best of both worlds: high level language that has
fast libraries when required.

-Larry Bates
Feb 11 '06 #5
Experienced programmers learning Python should read this:

http://effbot.org/zone/python-objects.htm

Try to understand the advantages of this approach, and understand its
costs.

Essentially, everything you do in Python (or related languages)
involves resolving a name. Sometimes the number of dictionary look-ups
(name dereferences) required to do anything is very expensive in
runtime performance.

If your code is not compute-bound (as most codes are not; these days
communication-bound or limited by database performance are more common)
the increase in your own performance will be much more important. If
your code does do so much computing (as mine do) that performance
matters, you may still find Python useful, but it is less of a
slam-dunk.

mt

Feb 12 '06 #6
On Sat, 11 Feb 2006 12:49:32 -0800, diffuser78 wrote:
I have just started to learn python. Some said that its slow.
No, you can learn the basics of Python is only a few hours, and become
very proficient at it in days or weeks. It is much faster to learn Python
than to learn C.
Can somebody pin point the issue.


What is slow? Slow compared to what? Would you prefer to spend three days
writing a program that will run in twenty milliseconds, or three hours
writing the same program which runs in eighty milliseconds? Is the
computer's execution time more important than your development time? If
the computer's time is more valuable than your time, then you should be
writing in assembly language.

Python helps you write shorter code with fewer bugs, much quicker, than C.
If you discover a specific problem that runs too slow in Python, it is
possible to write a C extension to solve that specific problem, while
still having all the other advantages of Python.
--
Steven.

Feb 12 '06 #7
On Sat, 11 Feb 2006 13:52:03 -0800, bearophileHUGS wrote:
Yes this language is very slow,


Very slow to do what, compared to what? The decay time of the tau meson?

Slowness is not an absolute quantity. Slowness is relative, and comments
like "Python is very slow" just reinforces the meme that execution speed
is the only important factor -- even if you follow up with a good (and
correct) description of why raw CPU speed is rarely an issue, it is too
late, you've reinforced the meme "only C is good".

I would challenge the assertion that *any* serious modern language is
"very slow" on modern hardware in any meaningful sense. There are plenty
of *specific tasks* which are too slow when written in one language or
another, but that's not the same thing.
--
Steven.

Feb 12 '06 #8
Steven D'Aprano>Very slow to do what, compared to what? The decay time
of the tau meson?<

Probably every answer I can give you is wrong for you, so answering is
almost useless... In this thread we have already given the most
pertinent answers to the original question from Diffuse.
I can show you this page, but I think this is useless too for you:
http://shootout.alioth.debian.org/gp...on&lang2=ocaml

And, by the way, this is false:
Robert Hicks>Python is fast enough for just about anything you want to
do with it.<

If you are on a Unix-like OS, then the page about Weave from SciPy can
show you that sometimes Python isn't quick enough.

Bye,
bearophile

Feb 12 '06 #9

be************@ lycos.com wrote:
Steven D'Aprano>Very slow to do what, compared to what? The decay time
of the tau meson?<

Probably every answer I can give you is wrong for you, so answering is
almost useless... In this thread we have already given the most
pertinent answers to the original question from Diffuse.
I can show you this page, but I think this is useless too for you:
http://shootout.alioth.debian.org/gp...on&lang2=ocaml


This is even more interesting:

http://shootout.alioth.debian.org/gp...thon&lang2=lua

However, to me, the strength of python is the batteries that is
included(and there are more and more coming).

Feb 12 '06 #10

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

Similar topics

49
2818
by: Ville Vainio | last post by:
I don't know if you have seen this before, but here goes: http://text.userlinux.com/white_paper.html There is a jab at Python, though, mentioning that Ruby is more "refined". -- Ville Vainio http://www.students.tut.fi/~vainio24
52
3807
by: Neuruss | last post by:
It seems there are quite a few projects aimed to improve Python's speed and, therefore, eliminate its main limitation for mainstream acceptance. I just wonder what do you all think? Will Python (and dynamic languages in general) be someday close to compiled languages speed? What will be the future of Psyco, Pypy, Starkiller, Ironpython and...
114
9726
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
68
5807
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
6
1867
by: km | last post by:
Hi all, Why is it that the implementation of empty loop so slow in python when compared to perl ? #i did this in python (v 1.5) for x in xrange(1000): print x # this took 0.017 seconds -------------------------- #similar code in perl (v 5.6):
118
6636
by: 63q2o4i02 | last post by:
Hi, I've been thinking about Python vs. Lisp. I've been learning Python the past few months and like it very much. A few years ago I had an AI class where we had to use Lisp, and I absolutely hated it, having learned C++ a few years prior. They didn't teach Lisp at all and instead expected us to learn on our own. I wasn't aware I had to...
83
3588
by: Licheng Fang | last post by:
Hi, I'm learning STL and I wrote some simple code to compare the efficiency of python and STL. //C++ #include <iostream> #include <string> #include <vector> #include <set> #include <algorithm> using namespace std;
33
3683
by: llothar | last post by:
I'm afraid that the GIL is killing the usefullness of python for some types of applications now where 4,8 oder 64 threads on a chip are here or comming soon. What is the status about that for the future of python? I know that at the moment allmost nobody in the scripting world has solved this problem, but it bites and it bites hard. Only...
57
2629
by: dongie.agnir | last post by:
I'm pretty new to Python, and even newer to Image/Video processing, and trying to get started on a project similar to GRL Vienna's laser marker. I found some sample code here http://janto.blogspot.com/2006/01/motion-capture-in-python.html, but after running the code with the included sample input file, it seems quite slow (1-2 seconds from...
0
7625
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...
0
8144
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7692
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...
0
6313
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...
0
5244
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...
0
3677
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...
1
2128
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
1
1235
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
969
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...

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.