This isn't tested, but intuitively I would expect skipping the intermediary float conversion would be helpful. You want to grab the integer to the left of the decimal, so I would try doing that directly via regular expression:
import re
pattern = re.compile("\d+")
Then replace the float parsing with the regex match:
sum(int(pattern.search(item).group(0)) for item in big_list[start:end] if item)
If you don't need to keep the old decimal strings, you could also get these on the fly as you build big_list
. For example, say we have the line "6.0,,1.2,3.0,"
. We could get matches like this:
delim = ","
pattern = re.compile("(\d+)\.\d+|" + re.escape(delim) + re.escape(delim) + "|$")
The results of this pattern on the line would be: ['6', '', '1', '3', '']
, which could then be sliced and filtered as usual without the need of float parsing:
for line in open(filename, 'r'):
big_list = pattern.findall(line)
a = sum(int(item) for item in big_list[start:end] if item)