[Tutor] Filling orders FIFO

Izz ad-Din Ruhulessin izzaddin.ruhulessin at gmail.com
Sat Jul 16 15:53:06 CEST 2011


Why are you doing it at the low level? Have you consideren using a framework
like Django for example?

2011/7/16 Steven D'Aprano <steve at pearwood.info>

> Charles John wrote:
>
>> Hi I am new to python and was wondering what the best way to create an
>> order(bid and offer) queue, then match a bid and offer so that if
>> bid==offer, creates a filled order FIFO in python cgi using mysql? Does
>> anybody have any ideas? It would be greatly appreciated.
>>
>
> The simplest way to use a queue is with a list:
>
> queue = []
>
> You push items onto the queue with queue.append(item) and pop them off with
> queue.pop(0).
>
> However, popping items may be slow if the queue grows very large (tens of
> thousands of items). It might be better to use a deque (double ended queue)
> instead of a list:
>
> from collections import deque
> queue = deque()
>
> To push items onto the right hand side of the queue, then pop them off the
> left hand side:
>
> queue.append(item)
> queue.popleft()
>
>
> As for the rest of your question, I don't understand what you mean by an
> order(bid and offer) queue. Perhaps you could give an example of what you
> mean.
>
>
> --
> Steven
> ______________________________**_________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110716/4a45d6e9/attachment.html>


More information about the Tutor mailing list