The following command with shallow copy (s[:]
) will create a view of s
for you that its elements are type of int
so after assignment it tries to assign the elements created by [i*weight for i in s]
to int
container but as your result are C long it raise the following error :
OverflowError: Python int too large to convert to C long
If you just use [i*weight for i in s]
you'll see the result as well :
>>> [i*weight for i in s]
[-1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60, -1.5608596215653603e+60]
Instead you can multiple directly :
>>> s = s*weight
>>> s
array([ 2.70765983e+42, 3.04611731e+42, 3.21534605e+42,
2.53843109e+42, 4.56917596e+42, 4.39994722e+42,
2.19997361e+42, 5.75377713e+42, 6.43069209e+42,
6.09223461e+42, 7.27683579e+42, 7.10760705e+42,
8.12297948e+42, 8.46143696e+42, 9.30758066e+42,
9.64603814e+42, 1.18460117e+43, 1.13383255e+43,
1.09998681e+43, 1.43844428e+43, 1.67536452e+43,
1.59075015e+43, 1.52305865e+43, 1.89536188e+43,
2.13228211e+43, 2.19997361e+43, 2.40304810e+43,
2.03074487e+43])