This is a collection of short Python scripts I use as utility tools or just for testing of various features.
compare_memory_usage_lst_comp_v_gen.py
-
Author: Kamil Adamski
-
Created at: 2020.06.21
Description:
This module shows a difference in memory usage between using list comprehension and generators. The results clearly show that list comprehensions have excessive memory usage unlike generators. The latter use a strictly defined storage space, regardless of the length of iterable. In addition, the computing time for using iterable is much less than list comprehensions.
Results:
total time execution time of function generate_suqares_using_list_comprehensions: 7.9959259033203125
get size of function generate_suqares_using_list_comprehensions results 859724472
total time execution time of function generate_suqares_using_generators: 0.0
get size of function generate_suqares_using_generators results 120
convert_yaml_to_json.py
-
Author: Kamil Adamski
-
Created at: 2020.06.28
Description:
This module converts a yaml file to the json file.
Results:
yaml file
object: foo meta: name: foo type: foo_type class: foo_class --- object: moo meta: name: moo type: moo_type class: moo_class
json file (after conversion)
[{
"meta": {
"class": "foo_class",
"name": "foo",
"type": "foo_type"
},
"object": "foo"
}, {
"meta": {
"class": "moo_class",
"name": "moo",
"type": "moo_type"
},
"object": "moo"
}]create_linked_list.py
-
Author: Kamil Adamski
-
Created at: 2020.07.26
Description:
This program creates a linked list and prints the total number of nodes.
Program:
example_elements = [1, 3, 6, 2, 1, 5] linked_list = LinkedList(example_elements) linked_list.create() head_node = linked_list.nodes[0] linked_list.count_number_of_nodes(head=head_node)
Results:
Total number of nodes equals to: 6