RomanOnARiver,
@RomanOnARiver@mastodon.social avatar

Is it better to have multiple python lists or one giant list with multiple lists embedded? Taking from perspective of speed and ram/CPU usage.

diazona,
@diazona@techhub.social avatar

@RomanOnARiver Probably depends on what you're doing with them?

I guess the RAM usage would likely be more with multiple lists, although probably not much more. But other than that it could be context-dependent.

meejah,
@meejah@mastodon.social avatar

@diazona @RomanOnARiver You cannot optimize without some tests.

So write a test that measures the thing you want to optimize (i.e. memory usage, or CPU usage) and then "try it and see". That said, I wouldn't expect there to be a huge difference between the two scenarios. (And as commented elsewhere, if the amount of data isn't "huge" it might not make any practical difference anyway)

RomanOnARiver,
@RomanOnARiver@mastodon.social avatar

@meejah @diazona yeah you both made a good point. Thanks for responding. I guess I also don't want to have someone reading that code and going "wow they did it THAT way? terrible."

meejah,
@meejah@mastodon.social avatar

@RomanOnARiver @diazona If you have a comment that says "I tested X and Y and they use about the same memory" then that person will be demonstrably wrong ;)

RomanOnARiver,
@RomanOnARiver@mastodon.social avatar
  • All
  • Subscribed
  • Moderated
  • Favorites
  • python
  • kavyap
  • thenastyranch
  • ethstaker
  • osvaldo12
  • mdbf
  • DreamBathrooms
  • InstantRegret
  • magazineikmin
  • Youngstown
  • khanakhh
  • Durango
  • slotface
  • rosin
  • cubers
  • JUstTest
  • everett
  • cisconetworking
  • tacticalgear
  • ngwrru68w68
  • Leos
  • GTA5RPClips
  • normalnudes
  • modclub
  • tester
  • anitta
  • megavids
  • provamag3
  • lostlight
  • All magazines