Python Programming Contest Questions

Asked 2 years ago, Updated 2 years ago, 69 views

I'm preparing to participate in the programming competition There's a site where you can test it in advance, so I tested it

I got a perfect score for accuracy, but I didn't get a single score for efficiency

I wrote down the code by reducing the repetitive sentences that I didn't write, but I didn't get an efficiency score

Is there any way to shorten the execution time on Python?

python big-o

2022-09-22 15:57

1 Answers

I understand that the time limit for each language is different If you want to make an absolute comparison of the performance of all languages, no matter how efficiently you write it in Python, you can't beat the performance of roughly written C.

In other words, Python is at the bottom of the list of languages that are currently used a lot.

If performance, or cpu operations, is high, Python alone has limitations.

반대로 가장 빠른 언어는 어셈블리와 c언어입니다.

There are two main ways to overcome the limitations of performance in Python.

The first is to use the JIT compiler, and the second is to use modules made of c or assembly in Python.

The first case is pypy, pystone, etc.

In the second case, you can invoke the so, dll file using the default built-in module, ctypes, and you can create the extension module immediately using cyton.

But the test site won't be able to use the above two methods.

It is unlikely that a JIT compiler such as pypy is installed on the test site, and the expansion module needs to be moved to the equipment, but it cannot be supported.


2022-09-22 15:57

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.