
Python tricks 101 - gzeus
I wrote a blog on python tricks, https:&#x2F;&#x2F;hackernoon.com&#x2F;python-tricks-101-2836251922e0<p>Please give me some suggestions on things to add.
======
gus_massa
The trick to reverse a number is probably awfully slow.

    
    
      print(int(str(num)[::-1]))
    

Unless the Python compiler has a huge bigger amount of magic than what I
imagine is possible, this code is very slow.

It's not so bad if you run it once, but if you put it inside a thigh loop, the
performance would be awful. Never ever use a string to transform a number into
another number in any language.

Perhaps you can try to make a post with a benchmark comparing this method and
another method that only use integer division (and perhaps other that use
floating point division).

~~~
gzeus
I just wanted to go with simple one-liners. But you are right.

Yes, I will try that. Thanks for the tip.

------
Tomte
Please read the guidelines on how to submit on this site.

You should have filled the URL field, not the text field. Like you did three
days ago, that was good.

