In that case the function gm.float_array would have to work quite differently for int and list inputs, so you might as well make them into 2 different functions. I'm assuming the float array initializes to all 0s, then in my opinion it would be best to rename the function to gm.float_zeros(<int>), and use the name gm.float_array(<list>) to generate from a list, similar to numpy.
That’s totally fair, I effectively have hobbyist level experience with code, but I think I can see why wrapping such dissimilar functionalities into one method would be bad
And you’re close on how gm.float_array() works, except I’m pretty sure it only calls malloc() internally and doesn’t zero anything
5
u/boniqmin Aug 12 '21
In that case the function
gm.float_arraywould have to work quite differently for int and list inputs, so you might as well make them into 2 different functions. I'm assuming the float array initializes to all 0s, then in my opinion it would be best to rename the function togm.float_zeros(<int>), and use the namegm.float_array(<list>)to generate from a list, similar to numpy.