It’s a built in script editor for some ancient software I’m doing QA / unit test writing for, The whole application looks pretty bad. Syntax highlighting is also extremely broken, of course. No proper code completion either
It cannot support that, because you can't overload assignment. If you write
int_array = [14.125]*1000
then int_array is overwritten and is now just a list rather than the object from gm. gm would need to have another function to construct the object from a list.
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
This is a unit test for a SWIG generated python wrapper if a C++ SDK. That means that sometimes you need to pass a pointer instead of a normal object, thus id()
263
u/bugqualia Aug 11 '21
Is this python? More serious problem is happening in syntax highlighting. What IDE is that shit?
122
u/_default_username Aug 11 '21
Lol, you came here to make fun of some bad code, but people are slamming on your text editor instead😄
37
u/GeneticalTM Aug 11 '21
Lines 74 and 75 can be reduced to
[14.25] * 1000ifgm.float_arraysupports it, which it should.12
u/WpGgs Aug 11 '21
I'm curious, why using the id function?
51
u/[deleted] Aug 11 '21
White background is probably the most disturbing thing I am seeing in this picture
6
u/choseusernamemyself Aug 11 '21
also if it's already an array, why use range(...)? it's unsafe
3
u/Risk_exe Aug 12 '21
The author is not stupid for naming the array 'int_array'
your IDE/text editor is poorly designed for highlighting 'int' in python.
52
u/alexanderhameowlton Aug 11 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
7
u/keethraxmn Aug 11 '21
I'm sure it's just short for internal array...
/s
3
u/Ancient2 Aug 12 '21
*throw up emojii" on PC
1
u/DangerousWish2266 Aug 12 '21
These type of people have special place in hell!