4
If not, do you know of a good non-standard module? I would need to work with stack, but I find it very strange that there is no module stack (stack) standard in Python and at the same time there is a module queue (queue).
4
If not, do you know of a good non-standard module? I would need to work with stack, but I find it very strange that there is no module stack (stack) standard in Python and at the same time there is a module queue (queue).
4
No. The standard language recommendation is use a list as a stack (stack).
In the case of a queue (Queue), additional methods and restrictions are required for the queue to be handled correctly. There are several types of queue, namely:
Queue (FIFO, First In, First Out)LifoQueue (Last In, First Out)PriorityQueue (in increasing order of value)Browser other questions tagged python-3.x stack
You are not signed in. Login or sign up in order to post.
If you want behavior Last In, First Out, yes.
– Leonel Sanches da Silva
So. That alone makes the implementation of
stackseparately.– Leonel Sanches da Silva
@nbro From what I understand of the cited links, the main difference between using a list as a stack and using a
LifoQueueis that the latter is thread-safe - and therefore should be less efficient if you are working with a single thread.– mgibsonbr