Script for trying to reproduce https://laurenar.net/posts/python-simd/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
try: | |
from numba import jit | |
except: | |
def jit(**kwargs): | |
return lambda f: f | |
@jit(nopython=True) | |
def arr_sum(arr): | |
total = 0 | |
for i in range(len(arr)): | |
total += arr[i] | |
return total | |
# Invariant: Always has the same elements and thus the same sum. | |
l = list(range(65000)) | |
def a(): | |
random.shuffle(l) | |
def b(): | |
return arr_sum(l) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment