Python Forum
Thread Rating:
  • 5 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can I do this faster?
#4
Another way could be using numpy (if your t and n fit into int32) - you are doing exactly same operation on list of numbers, if you transform it to 1-D array, you can manipulate them all at once. I am not sure if there is modular exponentiation in numpy - if not, to avoid overflow (and to speed it) you will need to implement it. With  binary exponentiation it could by quite fast.
Reply


Messages In This Thread
Can I do this faster? - by Gasimoe - Feb-28-2017, 06:22 PM
RE: Can I do this faster? - by nilamo - Feb-28-2017, 06:37 PM
RE: Can I do this faster? - by stranac - Feb-28-2017, 07:19 PM
RE: Can I do this faster? - by zivoni - Feb-28-2017, 08:00 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020