Type conversion for PyObjectList to kotlin FloatArray
See original GitHub issueIs there faster/efficient way for converting list of PyObjects to FloatArray ? Currently I am using following method.
private fun convertPyDataToFloat(list: List<PyObject>?): FloatArray {
val size = list?.size ?: 0
return FloatArray(size){ i->list!![i].toFloat()}
}
However for an array of 512 obj it is taking upto 1000-2000ms
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
toFloatArray - Kotlin Programming Language
Returns an array of Float containing all of the elements of this generic array. Common. JVM. JS. Native. 1.0. fun Collection<Float>.
Read more >Creating a FloatArray from an Array<Float> object in Kotlin
I am trying to convert a Array object to ...
Read more >Convert Array to List in Kotlin - Baeldung
In this tutorial, we'll explore how to convert an Array into a List in Kotlin. Though in practice these two data structures differ ......
Read more >Kotlin Program to Convert List (ArrayList) to Array and Vice ...
In this program, you'll learn to convert a list to an array using toArray() and array to list using asList() in Kotlin.
Read more >Convert Array<Any> to Array<Int> in Kotlin | Techie Delight
This will work fine for arrays of different types when an element in the source array can be stored in the destination array....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Since Chaquopy version 8.0.0, NumPy arrays and Java arrays of the same type can now be converted directly, which gives much better performance.
On the Python side, I think you can convert the FFT result to bytes using
tobytes
. Then usetoJava
to convert that to aByteArray
.