Is this a sequence coming in from a stream?
We can do this efficiently in python even if its a infinite stream of numbers coming in on a port or something.
Let me know the exact requirements and I should be able to help you. I have done somethings like this earlier.
Regards,
Prashant Tiwari