Horje
optimization in python Code Example
optimization in python
OPTIMIZATION FOR PYTHON: TIP 2 - 4

2 - When importing modules you can import them all in a single line:

import module_1, module_2, module_3, etc...


3 - When importing everything from a module use *:

from random import *

We imported everything from the 'random' module using *, now we dont need to use 'random.'
FUN FACT: Not using module. increases performance since module. uses the get_attr function which
decreases performance


4 - When importing only a few things from a module combine the two tips above:

from random import randint, choice

#Now we only import the things we want while also iincreasing performance and start-up time




Python

Related
code to printing a binary search tree in python Code Example code to printing a binary search tree in python Code Example
how to send message to specific channel discord/py Code Example how to send message to specific channel discord/py Code Example
Iterate string 2 characters at a time in python Code Example Iterate string 2 characters at a time in python Code Example
Python soma nĂºmeros Code Example Python soma nĂºmeros Code Example
ordereddict move to end Code Example ordereddict move to end Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8