Both sides previous revision
Previous revision
Next revision
|
Previous revision
|
python3 [2018/08/09 11:29] jguerin |
python3 [2019/05/07 14:52] (current) jguerin |
| |
===== When to use Python3 ===== | ===== When to use Python3 ===== |
While efficiency of a //program// is key to solving many contest problems, efficiency of the //programmer// is also critically important. Python3 is known for its expressive nature: problems that are solvable in Python3 are often solvable in far fewer lines than would be required in [[cpp_ref|C++]] or Java((At the time of the initial version of this guidebook, Java is not currently supported by the guidebook authors.)). Some of the easiest real-world contest problems can be solved in fewer than 5 or 10 lines of Python3 code. A firm grasp of Python3 may make the difference in solving easy and medium level problems, and doing so faster than other competitors. | While efficiency of a //program// is key to solving many contest problems, efficiency of the //programmer// is also critically important. Python3 is known for its expressive nature: problems that are solvable in Python3 are often solvable in far fewer lines than would be required in [[cpp|C++]] or Java((At the time of the initial version of this guidebook, Java is not currently supported by the guidebook authors.)). Some of the easiest real-world contest problems can be solved in fewer than 5 or 10 lines of Python3 code. A firm grasp of Python3 may make the difference in solving easy and medium level problems, and doing so faster than other competitors. |
| |
===== When not to use Python3 ===== | ===== When not to use Python3 ===== |
| |
The reverse is also true. Python3 may be the //wrong// choice for other problems. While Python3 boosts programmer efficiency, it inherently lacks runtime efficiency. Python3 cannot compete with well written [[cpp_ref|C/C++]]/Java code. Certain contest problems may not be solved within prescribed time bounds using Python3. | The reverse is also true. Python3 may be the //wrong// choice for other problems. While Python3 boosts programmer efficiency, it inherently lacks runtime efficiency. Python3 cannot compete with well written [[cpp|C/C++]]/Java code. Certain contest problems may not be solved within prescribed time bounds using Python3. |
| |
Fortunately, while a wrong choice of Python3 can be a (potentially major) setback in an actual competition, Python3 code follows many common pseudocode conventions and can be quickly converted to [[cpp_ref|C++]] or Java code. Such converted code is likely to perform significantly even before it is deliberately fine tuned. | Fortunately, while a wrong choice of Python3 can be a (potentially major) setback in an actual competition, Python3 code follows many common pseudocode conventions and can be quickly converted to [[cpp|C++]] or Java code. Such converted code is likely to perform significantly before it is optimized. |
| |
Python3 is a natural choice for many of the problems that are selected for the first half of a programming contest. | Python3 is a natural choice for many of the problems that are selected for the first half of a programming contest. |
| |
===== Input/Output ===== | ===== Input/Output ===== |
* [[python3_basic_io|Basic IO]] operations | * [[python3:input|Input]] for Programming Contests |
* [[python3_faster_io|Faster IO]] for competitive programming | * [[python3:output|Output]] for Programming Contests |
| |
===== Data Structures ===== | ===== Data Structures ===== |
| |
===== Functional Programming ===== | ===== Functional Programming ===== |
| ==== Recursion ==== |
| * [[python3:recursion_depth|Recursion Limits]] |
| |
==== Higher Order Functions ==== | ==== Higher Order Functions ==== |
* [[python3:functional_intro|Introduction]] | * [[python3:functional_intro|Introduction]] |
| * [[python3:list_comprehensions|List Comprehensions]] |
* [[python3:map_reduce_filter|Map, Reduce, and Filter]] | * [[python3:map_reduce_filter|Map, Reduce, and Filter]] |
* [[python3:lambdas|Lambda Expressions]] | * [[python3:lambdas|Lambda Expressions]] |
| |
| ==== Memoization ==== |
| * [[python3:lru_cache|Automatic Memoization: LRU Cache]] |
| |
| ===== Generators ===== |
| * [[python3:itertools|Itertools]] |
| * [[python3:generators|Generators]] |
| |
===== Mathematical Types and Operations ===== | ===== Mathematical Types and Operations ===== |