-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Python] Array sort functions not implemented #3638
Comments
Yes, there's quite a few functions not working with arrays. May I ask what use-case you have for arrays? I'm a bit unsure what to do with arrays for Fable Python. Currently they transpile to bytearray (uint8), list (generic) or array.array (everything else) depending on the type. But this makes it hard to add functions that works across all the types. I see pyodide translates to lists for js arrays, but using only likes makes interop with libraries that needs bytes or bytearrays (networking libraries etc). One option is to use numpy arrays, but then we require quite a large dependency (and there might be version conflicts with the user is already using a different version of numpy). Any suggestions or thouhts? |
@dbrattli thank you for your reply and your efforts in general! I see, that sounds like a really tricky problem to solve. I think in my case it's technically not really a special case. We are comparing the values of two dictionaries. But as they are basically randomly sorted in .NET, we first sort by the keys. My first naive intuition would be to try to create a very low level API for functionality on all of the types you mentioned and put the functions like sort on top. Unfortunately, I can't offer any opinion on the specific types and libraries you mentioned, as my Python knowlegde is mostly stemming from my interaction with Fable 😅. For now, I'll make due with let sort (a : 'T []) =
#if FABLE_COMPILER_PYTHON
a |> List.ofArray |> List.sort |> Array.ofList
#else
a |> Array.sort
#endif |
Description
Array sorting functions fail.
Repro code
test.fsx
test.cmd
dotnet fable . --lang python python test.py
Expected and actual results
Expected result: should return sorted arrays
Actual result:
AttributeError: 'array.array' object has no attribute 'sort'
Related information
dotnet fable --version
: 4.5.0dotnet tool list/update/install
: 4.6.0@Freymaurer
The text was updated successfully, but these errors were encountered: