-
-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_stream_buffer_length() #12
get_stream_buffer_length() #12
Conversation
I see the point of the improvment! Thank you very much! |
The default value of pop() is -1, the last (youngest) elem of the array, not the oldest.
#5 commit: pop() changed to pop(0), I think it was a bug |
I read the thing afterwards, len() does the same think what I did
I think your first suggestion is correct! if someone has the reason to control every second the stream_buffer size, then your first solution is definitely the best way ...
Yes, it should be a FIFO stack, thanks! |
Hmm. I don't know. It would be logical, but I think python already does that. There is a conversion about len(): https://stackoverflow.com/questions/699177/python-do-python-lists-keep-a-count-for-len-or-does-it-count-for-each-call |
i am thinking about it ... on the other hand, the stream_buffer should be almost 0 all the time, so its a bigger waste to count hundreds of +/- 1 operations per second, if you dont need them. |
True. And what is with sys.getsizeof? :) |
I can't update the documentation (https://www.unicorn-data.com/unicorn-binance-websocket-api.html), so if you want, you need to add get_stream_buffer_length() |
Its because, if I count the size this way, its compare able to the self.total_received_bytes value. But if i use the size of the stream_buffer variable itself, its very different. not only the raw data is used in the size, also the metadata for the complete list object of the stream_buffer and we receive a json and convert it! But at least its not accurate information, we should switch to use the data from the stream_buffer itself.
Thanks, I will do it asap! |
Its done, changes are available in the new release: https://github.com/unicorn-data-analysis/unicorn-binance-websocket-api/blob/master/CHANGELOG.md#138 |
Cooool! |
I needed a function that returns the number of items in buffer. If you find it useful, feel free to pull :)
(And the performance of get_stream_buffer_length() is better than len(self.stream_buffer), but I don't think it matters very much.)