betcode-org / betfair

betfairlightweight - Betfair API-NG python wrapper (with streaming)
MIT License
428 stars 148 forks source link

Remove unnecessary conversion of dict values to list #531

Closed petedmarsh closed 1 year ago

petedmarsh commented 1 year ago

As {}.values() is already iterable there's no need to conver them to a list:

d = {'a': 1, 'b': 2}
a = [n for n in list(d.values())]
b = [n for n in d.values()]

a == b  # True
liampauling commented 1 year ago

Agreed but this is done on purpose to give the output a new object with no references to the cache which is going to be constantly updated by another thread, unless values has been updated in python to give a new object rather than a pointer?

liampauling commented 1 year ago

And you can see the error in the tests proving it

petedmarsh commented 1 year ago

Ah, yes of course.

It may be slightly more performant to iterate over the market_ids if set, I will bench mark and see.