Ask Your Question

Revision history [back]

On my computer (an old Mac), Sage 10.1.beta3, the gcd computation is slower than the second computation, as common sense would suggest:

sage: %time x = gcd(bytes_to_long(SHA256.new(data=b'first').digest())^e-35211653423, bytes_to_long(SHA256.new(data=b'second').digest())^e-156535482153)
CPU times: user 7.79 s, sys: 191 ms, total: 7.98 s
Wall time: 7.99 s
sage: %time y = bytes_to_long(SHA256.new(data=b'first').digest())^e
CPU times: user 2.7 s, sys: 59.7 ms, total: 2.76 s
Wall time: 2.76 s

What does take a long time is actually printing y. If I did

sage: %time bytes_to_long(SHA256.new(data=b'first').digest())^e  # note: omitting "y=" at the start

the timing would be the same: it prints

CPU times: user 2.7 s, sys: 51.2 ms, total: 2.75 s
Wall time: 2.78 s

and then it take a long time to actually print the answer.

On my computer (an old Mac), Sage 10.1.beta3, the gcd computation is slower than the second computation, as common sense would suggest:

sage: %time x = gcd(bytes_to_long(SHA256.new(data=b'first').digest())^e-35211653423, bytes_to_long(SHA256.new(data=b'second').digest())^e-156535482153)
CPU times: user 7.79 s, sys: 191 ms, total: 7.98 s
Wall time: 7.99 s
sage: %time y = bytes_to_long(SHA256.new(data=b'first').digest())^e
CPU times: user 2.7 s, sys: 59.7 ms, total: 2.76 s
Wall time: 2.76 s

What does take a long time is actually printing y. If I did

sage: %time bytes_to_long(SHA256.new(data=b'first').digest())^e  # note: omitting "y=" at the start

the timing would be the same: it prints

CPU times: user 2.7 s, sys: 51.2 ms, total: 2.75 s
Wall time: 2.78 s

and then it take takes a long time to actually print the answer. answer.

On my computer (an old Mac), Sage 10.1.beta3, the gcd computation is slower than the second computation, as common sense would suggest:

sage: %time x = gcd(bytes_to_long(SHA256.new(data=b'first').digest())^e-35211653423, bytes_to_long(SHA256.new(data=b'second').digest())^e-156535482153)
CPU times: user 7.79 s, sys: 191 ms, total: 7.98 s
Wall time: 7.99 s
sage: %time y = bytes_to_long(SHA256.new(data=b'first').digest())^e
CPU times: user 2.7 s, sys: 59.7 ms, total: 2.76 s
Wall time: 2.76 s

What does take a long time is actually printing y. If I did

sage: %time bytes_to_long(SHA256.new(data=b'first').digest())^e  # note: omitting "y=" at the start

the timing would be the same: it prints

CPU times: user 2.7 s, sys: 51.2 ms, total: 2.75 s
Wall time: 2.78 s

and then it takes a long time to actually print the answer.

answer. Indeed, going back to y from the first version:

sage: %time len(str(y))
CPU times: user 4min 8s, sys: 425 ms, total: 4min 9s
Wall time: 4min 9s
5038462

Computing the string representation of y takes 4 minutes. (The gcd is 1, and its string representation is pretty quick to compute ;)