Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
  • Obviously PEP8. Especially whitespace and abbrevations bug me: grn is so not more readable than green.
  • Some variables are unused, e.g. smbytefunc and tobytefunc.
  • Instead of clamp you can use numpy.clip.
  • Loops with range(len(...)) are probably better written with enumerate instead. If you have a list of images you can also just iterate over the contents, instead of using the indexes from range(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 and smid is more likely to get out of sync with each other. If you want a shortcut, maybe use a property for nimgs 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 than green.
  • Some variables are unused, e.g. smbytefunc and tobytefunc.
  • Instead of clamp you can use numpy.clip.
  • Loops with range(len(...)) are probably better written with enumerate instead. If you have a list of images you can also just iterate over the contents, instead of using the indexes from range(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 and smid is more likely to get out of sync with each other. If you want a shortcut, maybe use a property for nimgs 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 than green.
  • Some variables are unused, e.g. smbytefunc and tobytefunc.
  • Instead of clamp you can use numpy.clip.
  • Loops with range(len(...)) are probably better written with enumerate instead. If you have a list of images you can also just iterate over the contents, instead of using the indexes from range(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 and smid is more likely to get out of sync with each other. If you want a shortcut, maybe use a property for nimgs 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:

Bounty Awarded with 50 reputation awarded by Community Bot
added 130 characters in body
Source Link
ferada
  • 11.4k
  • 25
  • 65
  • Obviously PEP8. Especially whitespace and abbrevations bug me: grn is so not more readable than green.
  • Some variables are unused, e.g. smbytefunc and tobytefunc.
  • Instead of clamp you can use numpy.clip.
  • Loops with range(len(...)) are probably better written with enumerate instead. If you have a list of images you can also just iterate over the contents, instead of using the indexes from range(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 and smid is more likely to get out of sync with each other. If you want a shortcut, maybe use a property for nimgs 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 than green.
  • Instead of clamp you can use numpy.clip.
  • Loops with range(len(...)) are probably better written with enumerate instead. If you have a list of images you can also just iterate over the contents, instead of using the indexes from range(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 and smid is more likely to get out of sync with each other. If you want a shortcut, maybe use a property for nimgs 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 than green.
  • Some variables are unused, e.g. smbytefunc and tobytefunc.
  • Instead of clamp you can use numpy.clip.
  • Loops with range(len(...)) are probably better written with enumerate instead. If you have a list of images you can also just iterate over the contents, instead of using the indexes from range(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 and smid is more likely to get out of sync with each other. If you want a shortcut, maybe use a property for nimgs 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.
added 329 characters in body
Source Link
ferada
  • 11.4k
  • 25
  • 65

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.

added 1135 characters in body
Source Link
ferada
  • 11.4k
  • 25
  • 65
Loading
Source Link
ferada
  • 11.4k
  • 25
  • 65
Loading
lang-py

AltStyle によって変換されたページ (->オリジナル) /