question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type conversion for PyObjectList to kotlin FloatArray

See original GitHub issue

Is 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:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mhsmithcommented, Jun 15, 2020

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.

0reactions
mhsmithcommented, Aug 30, 2019

On the Python side, I think you can convert the FFT result to bytes using tobytes. Then use toJava to convert that to a ByteArray.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found