-
Notifications
You must be signed in to change notification settings - Fork 6
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
WIP: Minor code improvements #67
Commits on Feb 26, 2021
-
Use empty call to
super()
and use str.formatUse an emptry call to `super()` instead of hardcoding the arguments. Also use str.format instead of the % operator. This was chosen instead of f-strings since it allows to use the equivalent of %g.
Solomon1732 committedFeb 26, 2021 Configuration menu - View commit details
-
Copy full SHA for 32d3cde - Browse repository at this point
Copy the full SHA 32d3cdeView commit details -
Modify loop structures in some functions
Modified loop structures in some functions. Instead of constructing the lists one element at the time, iterators, genexprs, and list comprehensions are used in order to make the list building more efficient.
Solomon1732 committedFeb 26, 2021 Configuration menu - View commit details
-
Copy full SHA for c83089d - Browse repository at this point
Copy the full SHA c83089dView commit details -
Modify functions' internal list handling
Modified functions' internal list handlings. Instead of using temporary lists or building lists by repeatedly appending items, the modified functions now use list comprehensions, `list.extend`, genexps, and iterators to more efficiently build lists. Removed some declarations of `object` as parent class. Modified `PriceLevelList.insert` to use `bisect.insort` to avoid having to sort the list at each item insertion. Replace explicit super() calls with no args calls Replaced explicit calls to `super()` with either the no arguments version or outright deleted. Minor refractoring to reduce code reduplication Minor refractoring to reduce code reduplication.
Solomon1732 committedFeb 26, 2021 Configuration menu - View commit details
-
Copy full SHA for f6c1f26 - Browse repository at this point
Copy the full SHA f6c1f26View commit details -
Change % string oprator to alternatives
Changed % string operator occurances to f-string when possible, or to `str.format` when not.
Solomon1732 committedFeb 26, 2021 Configuration menu - View commit details
-
Copy full SHA for 3c641b6 - Browse repository at this point
Copy the full SHA 3c641b6View commit details -
Change the structure of a few functions
Changed the structure of a few functions, namely orderbook's __str__ function. Reduces code duplication. Also changed _get_order_ids_iter and _get_price_level_iter.
Solomon1732 committedFeb 26, 2021 Configuration menu - View commit details
-
Copy full SHA for 1d9ada2 - Browse repository at this point
Copy the full SHA 1d9ada2View commit details -
Removed `object` as parent class from various classes. This is because it is redundant in python 3.
Solomon1732 committedFeb 26, 2021 Configuration menu - View commit details
-
Copy full SHA for ae7be16 - Browse repository at this point
Copy the full SHA ae7be16View commit details -
Change function to use list comprehention
Changed function to use list comprehention instead of appending to the list one element at a time. Change how some functions work In `BlockCache.get_missing_in_range` used list comprehention instead of manually appending to a new list in a loop. In `OrderBook._get_order_ids` used `map` instead of manually yielding in a loop. In `MatchPriorityQueue` used a `namedtuple` as the element of the internal `queue` list. Used `any` with a generator expression in `contains_order` instead of the loop with `_, _, other_order_id, _` destructuring, utilizing the introduced `namedtuple`. In `insert` utilized the new `namedtuple` in the internal `cmp_items` function for maintainability and readability. Also in `insert` instead of creating a new sorted list for `self.queue` the queue is sorted in-place.
Solomon1732 committedFeb 26, 2021 Configuration menu - View commit details
-
Copy full SHA for 0c5f2c9 - Browse repository at this point
Copy the full SHA 0c5f2c9View commit details -
Use
next
with default valueNone
Used `next` with a default value of `None` instead of using `try-except` on `StopIteration`. Removed `u` prefix from string. The prefix is superfluous in python 3. Instead of checking `current_version` against individual numbers it is checked against a tuple of values. Change parameterized `super()` to empty `super()` Instead of calling `super()` with explicit parameter, an empty call to it is made instead.
Solomon1732 committedFeb 26, 2021 Configuration menu - View commit details
-
Copy full SHA for 21d790a - Browse repository at this point
Copy the full SHA 21d790aView commit details -
Change ValueError to TypeError when appropriate
Changed the raising of ValueError to TypeError when appropriate. Namely when an argument's type is checked. Likewise changed the tests to match the new exceptions thrown. In `bitcoinlib_main.py` moved some software structures out of a file's `with` statement in order to not hold the file open longer than necessary. In addition restructured a for-loop in a minor way in order to decrease the indentation level of the loop's body.
Solomon1732 committedFeb 26, 2021 Configuration menu - View commit details
-
Copy full SHA for 15c965a - Browse repository at this point
Copy the full SHA 15c965aView commit details -
Modify PriceLevelList to utilize bisect
Modified PriceLevelList to utilize bisect for various methods. In addition, modified the class to raise IndexError manually in some cases so as to hide implementation details.
Solomon1732 committedFeb 26, 2021 Configuration menu - View commit details
-
Copy full SHA for 6d2fa62 - Browse repository at this point
Copy the full SHA 6d2fa62View commit details -
Add a comment to improve code readability
Added a comment to improve code readability and highlight the difference between the two if cases. Also made the two cases one-liners.
Solomon1732 committedFeb 26, 2021 Configuration menu - View commit details
-
Copy full SHA for b451598 - Browse repository at this point
Copy the full SHA b451598View commit details