Skip to content

adamsqi/python-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python scripts

Python version License: MIT

This is a collection of short Python scripts I use as utility tools or just for testing of various features.

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

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"
}]

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages