This is a collection of short Python scripts I use as utility tools or just for testing of various features.
-
Author: Kamil Adamski
-
Created at: 2020.06.21
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
-
Author: Kamil Adamski
-
Created at: 2020.06.28
This module converts a yaml file to the json file.
Results:
object: foo
meta:
name: foo
type: foo_type
class: foo_class
---
object: moo
meta:
name: moo
type: moo_type
class: moo_class[{
"meta": {
"class": "foo_class",
"name": "foo",
"type": "foo_type"
},
"object": "foo"
}, {
"meta": {
"class": "moo_class",
"name": "moo",
"type": "moo_type"
},
"object": "moo"
}]-
Author: Kamil Adamski
-
Created at: 2020.07.26
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