niemasd / TreeSwift

TreeSwift: Fast tree module for Python 3
https://niema.net/TreeSwift
GNU General Public License v3.0
75 stars 14 forks source link

Refactor code, make it more python and squeeze out small performance gains. #26

Closed Uzaaft closed 1 year ago

Uzaaft commented 1 year ago

Original issue was #25. Scope of this PR:

Uzaaft commented 1 year ago

Reason for eb4cbac:

Simple microbenchmark, but:

image
Uzaaft commented 1 year ago

Microbenchmark for e287123:

image
Uzaaft commented 1 year ago

@niemasd Ready for initial review.

I've got additional changes that I want to run by you, for.example the usage of if-expressions:

image

Instead of

image

There is also a few variable assignments that should be changes. For.example the usage of all and next, as these are built in variables/functions into python.

Uzaaft commented 1 year ago

@niemasd Ready for initial review.

I've got additional changes that I want to run by you, for.example the usage of if-expressions: image

Instead of image

There is also a few variable assignments that should be changes. For.example the usage of all and next, as these are built in variables/functions into python.

What about the changes proposed here? @niemasd

niemasd commented 1 year ago

Ah, sorry, I missed that! Yes, both ideas (1: using if-else variable assignment expressions, and 2: renaming variables whose names conflict with built-in Python variables/functions/keywords) sound great!