- Obviously PEP8.
Especially whitespace and abbrevations bug me:
grn
is so not more readable thangreen
. - Some variables are unused, e.g.
smbytefunc
andtobytefunc
. - Instead of
clamp
you can usenumpy.clip
. - Loops with
range(len(...))
are probably better written withenumerate
instead. If you have a list of images you can also just iterate over the contents, instead of using the indexes fromrange(number_of_images)
. - It is less error-prone to keep just one list of
images/widgets/... than to keep the number of things as a separate
variable; e.g. both
nimgs
andsmid
is more likely to get out of sync with each other. If you want a shortcut, maybe use a property fornimgs
instead. - Using both Tk and Qt is not nice; (if you're already using Qt, than) try to minimise the number of (additional) dependencies in your application. I found this question this question for the screen size and it seems to work fine for this setup.
Let's start with downsamp
. I guessed that the mean
calls at the end
where a problem, because mean
comes up in the stats as well; searching
for that gives me
this Stackoverflow answer this Stackoverflow answer,
which adapted to the code gives a bit of a boost:
- Obviously PEP8.
Especially whitespace and abbrevations bug me:
grn
is so not more readable thangreen
. - Some variables are unused, e.g.
smbytefunc
andtobytefunc
. - Instead of
clamp
you can usenumpy.clip
. - Loops with
range(len(...))
are probably better written withenumerate
instead. If you have a list of images you can also just iterate over the contents, instead of using the indexes fromrange(number_of_images)
. - It is less error-prone to keep just one list of
images/widgets/... than to keep the number of things as a separate
variable; e.g. both
nimgs
andsmid
is more likely to get out of sync with each other. If you want a shortcut, maybe use a property fornimgs
instead. - Using both Tk and Qt is not nice; (if you're already using Qt, than) try to minimise the number of (additional) dependencies in your application. I found this question for the screen size and it seems to work fine for this setup.
Let's start with downsamp
. I guessed that the mean
calls at the end
where a problem, because mean
comes up in the stats as well; searching
for that gives me
this Stackoverflow answer,
which adapted to the code gives a bit of a boost:
- Obviously PEP8.
Especially whitespace and abbrevations bug me:
grn
is so not more readable thangreen
. - Some variables are unused, e.g.
smbytefunc
andtobytefunc
. - Instead of
clamp
you can usenumpy.clip
. - Loops with
range(len(...))
are probably better written withenumerate
instead. If you have a list of images you can also just iterate over the contents, instead of using the indexes fromrange(number_of_images)
. - It is less error-prone to keep just one list of
images/widgets/... than to keep the number of things as a separate
variable; e.g. both
nimgs
andsmid
is more likely to get out of sync with each other. If you want a shortcut, maybe use a property fornimgs
instead. - Using both Tk and Qt is not nice; (if you're already using Qt, than) try to minimise the number of (additional) dependencies in your application. I found this question for the screen size and it seems to work fine for this setup.
Let's start with downsamp
. I guessed that the mean
calls at the end
where a problem, because mean
comes up in the stats as well; searching
for that gives me
this Stackoverflow answer,
which adapted to the code gives a bit of a boost:
- Obviously PEP8.
Especially whitespace and abbrevations bug me:
grn
is so not more readable thangreen
. - Some variables are unused, e.g.
smbytefunc
andtobytefunc
. - Instead of
clamp
you can usenumpy.clip
. - Loops with
range(len(...))
are probably better written withenumerate
instead. If you have a list of images you can also just iterate over the contents, instead of using the indexes fromrange(number_of_images)
. - It is less error-prone to keep just one list of
images/widgets/... than to keep the number of things as a separate
variable; e.g. both
nimgs
andsmid
is more likely to get out of sync with each other. If you want a shortcut, maybe use a property fornimgs
instead. - Using both Tk and Qt is not nice; (if you're already using Qt, than) try to minimise the number of (additional) dependencies in your application. I found this question for the screen size and it seems to work fine for this setup.
- Obviously PEP8.
Especially whitespace and abbrevations bug me:
grn
is so not more readable thangreen
. - Instead of
clamp
you can usenumpy.clip
. - Loops with
range(len(...))
are probably better written withenumerate
instead. If you have a list of images you can also just iterate over the contents, instead of using the indexes fromrange(number_of_images)
. - It is less error-prone to keep just one list of
images/widgets/... than to keep the number of things as a separate
variable; e.g. both
nimgs
andsmid
is more likely to get out of sync with each other. If you want a shortcut, maybe use a property fornimgs
instead. - Using both Tk and Qt is not nice; (if you're already using Qt, than) try to minimise the number of (additional) dependencies in your application.
- Obviously PEP8.
Especially whitespace and abbrevations bug me:
grn
is so not more readable thangreen
. - Some variables are unused, e.g.
smbytefunc
andtobytefunc
. - Instead of
clamp
you can usenumpy.clip
. - Loops with
range(len(...))
are probably better written withenumerate
instead. If you have a list of images you can also just iterate over the contents, instead of using the indexes fromrange(number_of_images)
. - It is less error-prone to keep just one list of
images/widgets/... than to keep the number of things as a separate
variable; e.g. both
nimgs
andsmid
is more likely to get out of sync with each other. If you want a shortcut, maybe use a property fornimgs
instead. - Using both Tk and Qt is not nice; (if you're already using Qt, than) try to minimise the number of (additional) dependencies in your application. I found this question for the screen size and it seems to work fine for this setup.
Oh and now that I think of it: I'd rather (up/down)scale the images once when the setting changes and then only index into the already scaled version instead of doing that on every mouse move.
Oh and now that I think of it: I'd rather (up/down)scale the images once when the setting changes and then only index into the already scaled version instead of doing that on every mouse move.