Hi
Interesting topic (briefly read I confess); let me doing some remarks:
- if you're dealing with numbers (0 and 1 typically), then you can use numpy and vectorization to speed-up your code
- it can be combined with "slicing" to get and compare arrays/vectors
- have a look to numpy.array_equal to compare 2 arrays/vectors (never tested so far but I can imagine the size of the vector is not an issue),
If you cannot avoid loops, have a look to Numba library (http://numba.pydata.org)
Finally, interesting benchmarking has been done by the Nasa to compare C, Python, Julia languages among others, and C is much faster than Python
(type "Basic Comparison of Python, Julia, Matlab, IDL and Java (2018 Edition)" + Nasa on Google); it's also interesting to note than vectorization is very powerfull
Paul
Interesting topic (briefly read I confess); let me doing some remarks:
- if you're dealing with numbers (0 and 1 typically), then you can use numpy and vectorization to speed-up your code
- it can be combined with "slicing" to get and compare arrays/vectors
- have a look to numpy.array_equal to compare 2 arrays/vectors (never tested so far but I can imagine the size of the vector is not an issue),
If you cannot avoid loops, have a look to Numba library (http://numba.pydata.org)
Finally, interesting benchmarking has been done by the Nasa to compare C, Python, Julia languages among others, and C is much faster than Python
(type "Basic Comparison of Python, Julia, Matlab, IDL and Java (2018 Edition)" + Nasa on Google); it's also interesting to note than vectorization is very powerfull
Paul
n = 1000000; vect1 = np.random.randint(2,size = n); vect2 = np.copy(vect1); identical = np.array_equiv(vect1,vect2); ## now I change 1 value to 2 chang = np.random.randint(n, size = 1); vect2[chang] = 2; identical2 = np.array_equiv(vect1,vect2); extract_part = vect2[100 : 350]; [python]PUT CODE HERE