Python is not good for CP since it is slow. I... — DEV Community (2024)

Python is not good for CP since it is slow. I... — DEV Community (1)

Avi Aryan

Full-Stack Web Engineer at Toptal

  • Location

    India

  • Education

    B.E.

  • Work

    Software Engineer at Toptal

  • Joined

Python is not good for CP since it is slow.

It also has good support for very large numbers which encourages people to solve certain arithmetic related problems in the wrong way (you get TLE).

Python gives less control over the system memory it consumes (unlike c/cpp), a side-metric on which CP performance is measured.

Python is not good for CP since it is slow. I... — DEV Community (3)

There are many languages build for a specific purpose, Python is considered as high level language which come with many boiler plates which increases execution time(That couse TTL internally) and it is best for its simplicity and code readability.

In recent code Jam Qualification round I found the best python code, which contains less than 10 lines of code while for other submitions and you'll find plenty of code for the same solution. Check that out here... codingcompetitions.withgoogle.com/... (submitted this solution in 1 minute 53 sec)
[Note: This python guy have used CPP in next 2 submissions.]

Though, I agree with Avi after using python and Java.
Anyway, Language is just a syntax, CP is all about problem solving ,algorithms and competition.
So go ahead with any language.
CP is more harder than writing comments. Best of luck.

Python is not good for CP since it is slow. I... — DEV Community (5)

Avi Aryan

Full-Stack Web Engineer at Toptal

  • Location

    India

  • Education

    B.E.

  • Work

    Software Engineer at Toptal

  • Joined

In recent code Jam Qualification round I found the best python code, which contains less than 10 lines of code while for other submitions and you'll find plenty of code for the same solution.

I have had the same experience in the past CodeJam.

Python is not good for CP since it is slow. I... — DEV Community (7)

Probably you don't use python then. Every Judge has a 5x multiplier for python. And yes you can also control the memory in python. Don't discourage people for using python.

Python is not good for CP since it is slow. I... — DEV Community (9)

Krishna Purohit

SDE-1 at Amazon.

  • Location

    Hyderabad

  • Work

    SDE-1 at Amazon

  • Joined

Another main reason I think is that it has so much stuff built-in that when a newbie programmer learns python he doesn't need to understand concepts like how variables are stored in memory, which is important to understand in the case of languages like C/C++, now it may look like an advantage but all it does is makes us ignorant to the stuff which happens "under the hood". I don't think it has really to do with CP specifically, since many people learn C/C++/Java as their first language and hence use them for CP.

Python is not good for CP since it is slow. I... — DEV Community (11)

Aaryan Pakhrani

14,technophile gamer and programmer taking part in ZCO 2020

  • Joined

Did you know that you get more time in competitions if you use pyhton.

Python is not good for CP since it is slow. I... — DEV Community (13)

Avi Aryan

Full-Stack Web Engineer at Toptal

  • Location

    India

  • Education

    B.E.

  • Work

    Software Engineer at Toptal

  • Joined

Yes. And that may help you solve certain problems easier than C.

But I personally find that the higher-level abstractions of Python get in the way when solving problems that can only be solved by using low-level concepts.

For further actions, you may consider blocking this person and/or reporting abuse

Python is not good for CP since it is slow. 

I... — DEV Community (2024)

FAQs

Is Python good for CP? ›

Oftentimes, programmers wonder if knowledge in Python programming is enough to help them ace competitive coding. The answer is a resounding "yes!".

Why do people use Python when it is so slow? ›

Since Python is a dynamically typed language, which means that it doesn't know about the type of the variable until the code is run, it is incredibly flexible and enables us to use modular components created in other programming languages. For example, you could import a C++ program as a module into Python.

Why is Python so slow compared to C? ›

The reason that everyone calls Python slow is because of the primary implementation, CPython. CPython is interpreted, meaning that you load a text file into it and it will try to convert that into a sequence of actions to run, but it only does so one step at a time.

Is Python slow for competitive programming? ›

Yes, python is slow for cp. Switch to c++ asap. Also note that getting tle probably means ur algorithm was not optimized. Since most of the judges uses multipliers.

Which is better language for CP? ›

C++ is the most preferred language for competitive programming mainly because of its STL.

Which programming language is good for CP? ›

C++ and Java are the best languages for competitive programming. Most competitive programmers participate using C/C++. Java is the second most popular language for competitive programming.

Is Python the slowest language? ›

Python is a high-level programming language: The code of Python looks very similar to how humans think. For that reason, it must Separate the details of the computer from you: memory management, pointers,… Hence, it is slower than “lower-level language” like C.

How to speed up Python performance? ›

9 tips to improve Python performance
  1. Select correct data types.
  2. Know standard functions, methods and libraries.
  3. Find performance-focused libraries.
  4. Understand the different comprehensions.
  5. Use generator functions, patterns and expressions.
  6. Consider how to process large data.
  7. Run profiles to identify problematic code.
Oct 4, 2023

Why is Python so slow compared to C++? ›

Unlike C++ or Java, Python's standard interpreter, CPython, executes bytecode in a straightforward manner without the extensive optimizations seen in compiled languages or the JVM. This loop iterates and executes each step line-by-line, leading to typically slower execution.

What are the disadvantages of Python? ›

Cons of Python Programming
  • Python is Slow at Runtime.
  • Mobile Application Development.
  • Difficulty in Using Other Languages.
  • High Memory Consumption.
  • Not used in the Enterprise Development Sector.
  • Runtime Errors.
  • Simplicity.
Nov 2, 2023

Why can't Python be faster? ›

C and C++ do a complex compilation process to turn the source code into machine code that runs directly on the processor. Python does a simple compilation process that turns source code into tokens, and the Python interpreter steps through the tokens. Python will always be much slower.

What is faster C or Python? ›

It is said that python is 100 times slower than C.

How fast can I get good at Python? ›

If you're looking for a general answer, here it is: If you just want to learn the Python basics, it may only take a few weeks. However, if you're pursuing a career as a programmer or data scientist, you can expect it to take four to twelve months to learn enough advanced Python to be job-ready.

Which is better Python or C++? ›

C++ duel lacks a clear winner, as the better choice depends on individual preferences and project requirements. Python excels in quick learning and the rapid development of small programs. In contrast, C++ is suitable for large projects and exploring multiple languages, although it requires more time to master.

How much slower is Python to C? ›

C might run something in a few nanoseconds, and Python will be 1000x slower, and run it in a few milliseconds. Is that really going to have a major impact? Unless you are running this calculation millions of times, likely not. So don't worry about using Python even though it is slower than C.

What is CP in Python? ›

Implementation of the functionality of copy (cp) command in python. We are be able to copy files we are able to copy directories using a similar -r option, we are able to copy files forcefully using -f option and do not use any predefined libs that do the same like shutil, subprocess, etc. linuxcp. import os.

Should I use Python or C++ for competitive programming? ›

Speed : C++ is much more faster than Python. But, there is a time multiplier for Python in most of the judges. But if speed is the main concern go with c++. Lines of code : In this case, Python wins.

What is Python best suited for? ›

Python is commonly used for developing websites and software, task automation, data analysis, and data visualisation. Since it's relatively easy to learn, Python has been adopted by many non-programmers, such as accountants and scientists, for a variety of everyday tasks, like organising finances.

What is Python not good at? ›

One of the major drawbacks of this language is that its design has numerous issues. Python programmers face several issues regarding the design of the language. This language requires more testing and also it has errors that only show up at runtime this is because the language is dynamically typed.

Top Articles
Latest Posts
Article information

Author: Twana Towne Ret

Last Updated:

Views: 6068

Rating: 4.3 / 5 (64 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Twana Towne Ret

Birthday: 1994-03-19

Address: Apt. 990 97439 Corwin Motorway, Port Eliseoburgh, NM 99144-2618

Phone: +5958753152963

Job: National Specialist

Hobby: Kayaking, Photography, Skydiving, Embroidery, Leather crafting, Orienteering, Cooking

Introduction: My name is Twana Towne Ret, I am a famous, talented, joyous, perfect, powerful, inquisitive, lovely person who loves writing and wants to share my knowledge and understanding with you.