-
-
Save hzbd/5445739 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _shard_array(inlist, shard_size): | |
# inlist = 150-element list | |
# shard_size = 40 | |
num_shards = len(inlist) / shard_size | |
# num_shards == 3 | |
shards = [] | |
for i in range(num_shards): | |
# i == 0 | |
start = shard_size * i # start == 0, then 40, then 80... | |
end = shard_size * (i + 1) - 1 # end == 39, then 79, then 119... | |
shards.append(inlist[start:end]) | |
return shards |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment