2021年1月3日星期日

How could I improve the speed of my algorithm, even by the slightest amount

How can I improve the speed of my algorithm, even by the slightest amount. For the reason I made this I don't actually care about speed in the slightest, but I'm wondering what I could change if I did. Even more than pointing out specific things to change, what I really want to know is how you know that there's a more efficient way and how that way works. Basically, what is the track to follow if you want to learn how the low level stuff works so that you can write better code at the higher level.

def decode_all(ob):      if(type(ob)==list):          for i in range(len(ob)):              ob[i] = decode_all(ob[i])      if(type(ob)==dict):          for i in ob.copy():              ob[i] = decode_all(ob[i])              if(type(i)==bytes):                  ob[i.decode()] = ob[i]                  ob.pop(i)      if(type(ob)==tuple):          new_ob = []          for i in ob:              new_ob.append(decode_all(i))          ob = tuple(new_ob)      if(type(ob)==bytes):          return ob.decode()      return ob  

If you downvote this question, I'd really appreciate if you told me why because I don't want to waste anyone's time asking bad questions.

https://stackoverflow.com/questions/65555973/how-could-i-improve-the-speed-of-my-algorithm-even-by-the-slightest-amount January 04, 2021 at 07:26AM

没有评论:

发表评论