A Faster Nested Tuple to List and Back
I'm trying to perform tuple to list and list to tuple conversions on nested sequences of unknown depth and shape. The calls are being made hundreds of thousands of times, which is why I'm trying to squeeze out as much speed as possible. Any help is much appreciated. Here's what I have so far... def listify(self, seq, was, toBe): temp = [] a = temp.append for g in seq: if type(g) == was: a(self.listify(g, was, toBe)) else: a(g) return toBe(temp) And a call for tuple to list would look like this: self.listify((...), tuple, list) Edit: Yeah, I totally missed both the enumerate (from an old