https://github.com/utkarsh-deshmukh/python_queue
in python you can implement queue using various methods. This study is comparing the performance of these techniques
https://github.com/utkarsh-deshmukh/python_queue
Last synced: 10 days ago
JSON representation
in python you can implement queue using various methods. This study is comparing the performance of these techniques
- Host: GitHub
- URL: https://github.com/utkarsh-deshmukh/python_queue
- Owner: Utkarsh-Deshmukh
- Created: 2020-02-22T20:59:08.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-22T21:30:32.000Z (over 5 years ago)
- Last Synced: 2025-04-05T19:46:15.509Z (3 months ago)
- Language: Python
- Size: 60.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python_Queue
in python you can implement queue using various methods. This study is comparing the performance of these techniquesWe will take a look at two such methods: **Using List as a queue** and **using queue.Queue()**
Implementation:
### 1) Using List to implement a queue:
L = []
L.append(1) --> Adding 1 to the queue
L.append(2) --> Adding 2 to the queue
L.append(3) --> Adding 3 to the queue
L.pop(0) --> Popping the element at 0 : ans will be 1
L.pop(0) --> Popping the element at 0 : ans will be 2
L.pop(0) --> Popping the element at 0 : ans will be 3### 2) Using queue.Queue()
import queue
Q = queue.Queue()
Q.put(1)
Q.put(2)
Q.put(3)
Q.get() --> Popping the first element : ans will be 1
Q.get() --> Popping the first element : ans will be 2
Q.get() --> Popping the first element : ans will be 3
#######
We would like to see which implementation is more effective.
Note: For this test, I am comparing the time for inserting elements in the queue, and removing them
### **Results**:
### Conclusion:
The time needed to insert N elements using __queue.Queue()__ seems to increase w.r.t N, where as for the List implementation, the time is almost constantThe time needed to remove all N elements using __queue.Queue()__ seems to increase w.r.t N, where as for the List implementation, the time increases non linearly w.r.t N