arkouda icon indicating copy to clipboard operation
arkouda copied to clipboard

`sorted` in `dataframe.py` overrides the python builtin `sorted`

Open stress-tess opened this issue 2 years ago • 0 comments

The sorted method in dataframe.py overrides the python builtin sorted (the one actually referenced in the doc string)

https://github.com/Bears-R-Us/arkouda/blob/42ac6fbf838de7de9d3149ba9458096fff4cd428/arkouda/dataframe.py#L1849-L1852

It's worth noting this will not actually affect the users (since this will be under the ak namespace i.e. ak.sorted). But it could cause hard to debug issues popping up

Let's say we have a file (example.py) where we use python builtin sorted to sort a list, and then at some point in the future we have to import dataframe in example.py... now the builtin.sorted will be overridden by dataframe.sorted and seemingly random piece of code that we didn't touch will break. This can be handled by doing __builtins__.sorted(my_list), but this doesn't feel ideal

In general it's a really bad idea to override things from python's builtins. I'm not sure if we should deprecate this in favor of a class level df.sorted() function, or if this is just something we should live with since it's apart of our api and just add a comment for developers that this is overriding the builtin? What do others in @Bears-R-Us/arkouda-core-dev think?

stress-tess avatar Aug 30 '22 16:08 stress-tess