Jayson Santos: > Hello people, I'm writing a Bitmap parser for study purposes,
This code: x = 0 y = 0 for line in bmp.bitmap_lines.lines: for color in xrange(len(line.colors)): canvas.create_line(x, y, x+1, y, fill="#%02x%02x%02x" % (line.colors[color].red, line.colors[color].green, line.colors [color].blue)) x += 1 x = 0 y += 1 May be replaced with something like: for x, color in enumerate(line.colors): canvas.create_line(x, y, x+1, y, fill="#%02x%02x%02x" % (color.red, color.green, color.blue)) And maybe a RGBTriple may be replaced with an immutable namedtuple. Using nested classes may be overkill for this program. Use the Python profiler and profile your code with a real image, and show us/me the profiler results, so I can give you some suggestions to speed up your code. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list