Cloud Stack Ninja

I have code with this line:

binary = "".join([str(x) for x in arr])

I noticed that when I changed that for

binary = "".join(str(x) for x in arr)

Code execution slowed down (average 605 and 640 respectively). Why is that?

Whole code looks like this (input is a list of 0s and 1s):

def binary_array_to_number(arr):
    binary = "".join([str(x) for x in arr])

Read more here:

Content Attribution

This content was originally published by Jan Kowalski at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: