I don't understand why this question was closed, and then why it was deleted. Here is the question body:

Why is Python such a slow language, on average, compared to C/C++? I learned Python as my first programming language, but I've only just started with C and already I can feel and see the difference.

The title is argumentative (and should be replaced with 'Why does Python run more slowly than C?'), but this is not a subjective question. In general, Python code does run more slowly than C code. This is a fact. It's not a particularly surprising fact - Python is an interpreted language, and CPython is implemented in C. As the top answer states:

It is true that C code usually runs 10 to 100 times faster than Python code if you measure only the execution time. However if you also include the development time Python often beats C. For many projects the development time is far more critical than the run time performance.

This is an obvious beginner question someone new to Python might ask. There are two excellent, interesting technical answers, with 26 and 17 votes respectively. They are clear, unambiguous responses. I am a Python programmer. I am interested in the answers.

Does anyone really believe that rather than editing this, we're all just better off without it? If so, I'd be fascinated to hear your point of view. Otherwise, please vote to reopen. I'll even edit the title for you.

  • 2
    It's been asked a zillion times before about every other interpreted language. And I think several times about python. – nb69307 Jun 18 '10 at 20:01
  • 5
    @Neil: Really? Do you have any evidence for that statement? Did you actually look before you cast your delete vote? I haven't found any Python duplicate, no Perl version, and only one Ruby version, which apparently is perfectly acceptable - 8 votes, average answers, no close votes. One of the answers here is very specific to the Python implementation. If someone can prove this is a duplicate, then it deserves merging, not deleting. In any event, the close reason was 'subjective and argumentative'. This is simply not true. – ire_and_curses Jun 18 '10 at 20:20
  • 1
    @ire Well, stuff like stackoverflow.com/questions/2328495/… - taken at random. – nb69307 Jun 18 '10 at 20:39
  • 1
    @Neil - Not a duplicate. The answers are all specific to the code being optimised. – ire_and_curses Jun 18 '10 at 21:37
  • 1
    @ire_and_curses: And? "Slow" without qualifiers is next to meaningless - a language isn't slow, but programs written in a language might be. That's what makes language flame-wars so much fun! Back in the VB6 days, there were a handful of algorithms that, naively-implemented, were faster in VB than in C++. Shortly after Java showed up, there were Java programs that managed to beat out (again, unoptimized) C++ versions. And of course in both cases, countless examples of the reverse... But it's still the algorithm, compiler, and runtime that make a given routine execute slowly. – Shog9 Jun 19 '10 at 0:04
  • 2
    @Shog9: How does a new programmer make that distinction without asking the question? – Nicholas Knight Jun 19 '10 at 0:23
  • @Nicholas: he doesn't. That's what we're here for. – Shog9 Jun 19 '10 at 0:32
  • 3
    @Shog9: But his question was closed and deleted. How is he, or the many others inevitably to follow, going to find out the answer now? – Nicholas Knight Jun 19 '10 at 0:35
  • @Nicholas: how would they have found the answer if the question had stayed open? Do you see this point being made anywhere in the existing answers? I see a lot of (mostly-irrelevant) generalizations regarding compiled and interpreted languages, and a few explanations of how the normal Python runtime behaves in specific scenarios. By the time the question was deleted, we'd already failed the new programmer who asked it. – Shog9 Jun 19 '10 at 0:39
  • 3
    @Shog9 I can't see the existing answers. The question has been deleted. Not everyone has managed to accumulate 10k rep on SO. In fact, only about 600 people have, and based on relative activity levels in various languages, I doubt if even half of those pay attention to Python questions. – Nicholas Knight Jun 19 '10 at 0:41
  • @Nicholas: well, by my count there are 144 users with at least 10K rep points who've asked at least one Python question. So i'd say it's reasonably well represented... – Shog9 Jun 19 '10 at 1:04
  • The question has been undeleted. I'm rather interested to see if and how it gets edited now... – Shog9 Jun 19 '10 at 5:26
  • @nb69307: That'd make it "exact duplicate", not subjective and argumentative. – Andrew Grimm May 26 '11 at 0:09

I've been known as someone who likes to delete questions, but I just voted to undelete this one.

If it comes back, I'll help edit it to become the kind of question it needs to be, and will inform the OP of the reasons for my edits. I see no reason why this question could not have been cleaned up to begin with.


I can tell you why I voted. I can't explain anyone else, though from the comments it's clear that several people were motivated by a sense of déjà vu, however well or poorly justified. Others were concerned that the question, as phrased, was a giant flame magnet for debate -- subjective and argumentative. I don't have a great recipe for balancing the desire to help the newbies with the desire to avoid encouraging the trolls.

The entire question launches from an unproved premise. Who says that Python is slow? Slow compared to what? On What tasks? To be a real question, and not just a subjective opinion piece, it has to be specific. I can't tell you why 'Python is slow,' and neither can anyone else. I can tell you why a particular Python program is slower than a particular alternative.

It isn't a real question because there is no 'in principle' answer to this. If python had a JIT compiler like Java, it could very closely approach non-interpreted speeds for many tasks. On the other hand, a sufficiently messy C++ implementation can be slower than python.

To me, this launch from an unproved, and, to me, incorrect, premise is sufficient reason for NARQ.

Further, the title is important. It's what people see first. My personal practice is to vote to close NARQ or S&A for a title that is tendentious. (Though, I confess, I have been known to risk the wrath of some by editing such titles instead.)

If you really wanted to know the technical details about why a concrete Python implementation of some specific algorithm is incompressibly slower than a concrete compiled implementation, you could have posted such a question. It would be very unlikely that anyone, let alone 5-10 anyone's, would have voted against it.

  • 4
    Notice that your answer to why the question was closed includes a great deal of information about why Python is, in practice, slower. This is information a beginner will not have. Said beginner is also unlikely to have the experience necessary to determine if his programming-related question has a faulty premise. He needs someone to tell him that, and in simply closing and deleting the question, you have denied him the opportunity to learn these things that we take for granted. – Nicholas Knight Jun 18 '10 at 23:02
  • 1
    @Nic - Everyone is capable of finding a neutral tone to ask a question, and particularly a neutral tone for the title. Even asking 'Is python slower?' would have avoided setting off my touchy spot. Mostly, I didn't 'close and delete' his question. I was one vote out of 5 to close, and then later, after two days and no change to the question, one vote out of 5 to delete. People who disagreed were free to vote to reopen in those two days, or upvote the question and up the ante. They didn't. I vote to express my unbalanced opinion. I depend on the rest of the community to provide balance. – Rosinante Jun 18 '10 at 23:17
  • 4
    @Rosinante: How is the newbie going to know what's neutral? From his perspective, he's asking a perfectly normal question. He has clearly observed a behavior he doesn't understand, and asks why it exists. If I walk into a room at 40C and want to know why it's so hot, I'm going to ask "Why is it so hot in here?", not "Is it hotter in here?". I know it is, I'm not going to ask a question I don't need an answer to. – Nicholas Knight Jun 18 '10 at 23:38
  • 2
    @Nic your argument is a really good reason for someone to have cleaned up the question. Though, that wouldn't have stopped the 'duplicate' voters. Some days I do that sort of editing. Some days I have on my grumpy glasses and see a troll where you see a newbie. That's why we have a whole community. – Rosinante Jun 19 '10 at 0:27
  • 1
    @Rosinante: Then the community has failed spectacularly. Here you and Shog9 are admitting that there's a real question to be had and that there were useful answers present, yet you've acted not to educate the ignorant, but to bar their way, not because the question in itself is bad, but because you don't care for the form in which it was presented -- a form that the question is almost always going to take when it comes from a new programmer not familiar with the intricacies of interpreters and runtime environments in general. – Nicholas Knight Jun 19 '10 at 0:38
  • 2
    @Nic We acted to avoid the existence of a flame-bait question. It's not fair for you to criticize us for failing to excavate the pony from the pile of pony output. There is no question in itself. There's a hypothetical good question hiding inside a pile of tendentious text. Still, if you like, fine: the community flubbed this one. Communities will do that. "The problem with folk music is that it is written by the people." You like it so much? Vote to undelete! – Rosinante Jun 19 '10 at 0:58
  • 1
    @Rosinante: If in your eyes the only way for the community to deal with the issue is for everyone who disagrees to vote to undelete it, then the Stack Overflow community is limited to approximately 600 people who have reached 10k+ reputation. I don't think that's the case, nor do I think you do, so how about we discuss it carefully instead of throwing up our hands and telling helpless people "don't like it? fix it!"? – Nicholas Knight Jun 19 '10 at 1:03
  • 2
    @Nicholas: actually, the better way to deal with this issue is for you to come up with a good question to replace the one that was deleted, and then to ask it (assuming it hasn't been asked already...) That way, the question is represented and can be answered on SO, but we don't have to drag along all the baggage that has become attached to the one that was deleted... – Shog9 Jun 19 '10 at 1:06
  • 2
    @Shog9: As far as I'm concerned, the right question was already asked and deleted. If the answers weren't what they should have been, that's unfortunate, but another newbie is just going to ask exactly that question again. The whole reason you, Rosinante, Neil, and I'm sure many others react poorly to the question is because it gets asked so often in exactly that way (by both newbies and, yes, trolls). That tells me that this is the question that needs to be answered. The answer "You're asking the wrong question." is fine, in fact it's perfect, but they need to be told that specifically. – Nicholas Knight Jun 19 '10 at 1:12
  • 1
    @Nicholas: every new programmer wants to know which language is the best, which editor is the best, which operating system is the best, which method of indentation is the best... These questions are the epitome of subjective and argumentative, because everyone thinks they have an answer but rarely do they agree on what that answer is. And so, they provide a never-ending source of entertainment on newsgroups and message boards. But they're inappropriate for SO, for just that reason. If only it was possible to stop a flame war with a single, level-headed "there is no answer" answer... – Shog9 Jun 19 '10 at 1:38
  • @Nic this looks like a rather comprehensive discussion to me. The next time I see one of these, I'm rather more likely to take my chances in the edit lottery. Yes, undelete is still a small group, but edit and reopen are very available. Those are the community's mechanisms for sorting this kind of thing out. Why didn't people edit the question in the first place or reopen it in the second? I don't know. @ire_and_curses asked how this happened. We've offered some insight into how it happened. Perhaps you should write a new meta question offering a suggestion about avoiding this in the future? – Rosinante Jun 19 '10 at 1:41
  • See stackoverflow.com/questions/3073026/… for a clearer example of what we're trying to avoid here. – Rosinante Jun 19 '10 at 1:51
  • 1
    What is this fear over flaimbaiting? There are probably legitimate reasons for closing the question, but fear of flaimbaiting? If and when that actually occurs, then of course, close and delete the question with extreme prejudice. But closing a question over a fear that something bad might happen seems a bit absurd and ridiculous to me, almost as absurd as the notion of "giving the appearance of rep-whoring." Almost. – user102937 Jun 19 '10 at 2:18
  • @Rosinante: Thank you for stepping up and explaining your reasoning. It's interesting that you would push the 'slow is subjective' argument. Guido van Rossum himself said "Python programs are generally expected to run slower than Java programs". There is no JIT compiler I know of for Python. Regardless, the questioner is describing his real world experience, not some possible, optimised experience. The fact is, in day to day usage, Python takes longer to run than compiled languages. Usually that is not an issue. – ire_and_curses Jun 19 '10 at 3:16
  • 1
    @ire I'm not arguing any position on undelete/edit/whatever. I think @Shog9's explanation of the pitfalls of repair are material, however. You're welcome for your polite recognition that I tried to offer an explanation, not to win an argument, least of all one about the performance of Python. The factual question is a fascinating one that would make a great CW question entitled, perhaps, 'When can I expect Python code to be slower (or faster) than C?' @Rob maybe the 10k tools are getting to me, but I sometimes feel as if the hooligans are breaking windows faster than I can board them up. – Rosinante Jun 19 '10 at 12:46

Does anyone really believe that rather than editing this, we're all just better off without it?

I'll address this, as Rosinante has already done a decent job of explaining why the question, as it stood, should have been closed and deleted.

When I came across the question, it had been closed for two days. That's two days after it had been first asked. During this time, two users with enough rep to edit it had posted detailed and popular answers, and numerous other users had up-voted them. But no one had bothered commenting to dispute the S&A charge, and no one had edited it. I'll allow that it's possible someone could have deftly altered the tone and focus of that question, rendering it less argumentative and perhaps even less subjective. Perhaps even I, with a sufficient investment time and effort, could have accomplished this.

But I could not, at the time I voted to delete it, see a way to accomplish this without rendering one or both of the most popular answers off-topic.

Could I have edited both the question and its answers? Well, I have that ability. Whether such edits would have stood is another matter; but more important is the fact that I do not consider it appropriate to effectively re-create an entire discussion (and make no mistake, this is a discussion) based on personal taste while leaving other users' names attached. And I've been known to make some fairly dramatic edits on SO...

Now, if one of the users who put time into answering the question had also taken a few minutes to edit the question itself, toning down the argumentative language and removing some of the more subjective aspects, he could at the same time have written his answer with these same goals in mind. But this did not happen.

So yeah. In theory, there is a question akin to this that could be asked and answered without diving deeply into S&A territory. But this question wasn't it. If a beginning programmer wants to indulge themselves in idle discussion over the relative "speed" of different programming languages, there are a host of forums that allow this sort of thing.

Here's a question then, for those who would like to have seen that question open and answered: when it was closed, why did you not take that as a warning, and immediately strive to improve both the question and its answers? And if you felt that they were fine as-written, why did you not attempt to refute the charge of Subjective and Argumentative so clearly expressed in the close reason itself?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .