A couple potential optimizations: > > # create the member variable name. > mem_var_name = options.inputfilename > mem_var_name = mem_var_name.replace(' ','_') > mem_var_name = mem_var_name.replace('.','_') >
mem_var_name = options.inputfilename.replace(' ','_').replace('.','_') No need to assign it 3 times. > while i < len(hex_data): > outfile_c.write( "0x%c%c" % ( hex_data[i],hex_data[i+1] ) ) > i += 2 > if i != len(hex_data): > outfile_c.write(",") > if i % 32 == 0: > outfile_c.write("\n") This could be re-written as such: for x in xrange(0, len(hex_data), 32): output_c.write('%s\n' % ','.join(['0x%s'%''.join(['%c'%a for a in hex_data[x:x+32][i:i+2]]) for i in xrange(0, 32, 2)] -- http://mail.python.org/mailman/listinfo/python-list