[Tutor] Filling orders FIFO
Steven D'Aprano
steve at pearwood.info
Sun Jul 17 18:52:13 CEST 2011
Izz ad-Din Ruhulessin wrote:
> Why are you doing it at the low level? Have you consideren using a framework
> like Django for example?
Who is this question addressed to? Me?
If so, my answer is that Django is an awfully large dependency if all
you need is a queue.
But if you think that Django has a good solution to the problem, by all
means show us how you would use it.
P.S. we prefer that you don't top-post on this mailing list. It makes it
easier to understand replies if they follow what they are replying to,
rather than come before.
Steven.
> 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>
>>
>
More information about the Tutor
mailing list