[Tutor] Improving My Simple Game Code for Speed, Memory and Learning

WolfRage wolfrage8765 at gmail.com
Sun Jan 4 02:00:35 CET 2015


On 01/03/2015 06:46 PM, Steven D'Aprano wrote:
> On Sat, Jan 03, 2015 at 06:10:31PM -0500, WolfRage wrote:
>> On 01/03/2015 04:42 PM, Dave Angel wrote:
>>> self.transposed_grid = list( zip(*self.grid) )
>
>> This results in the same thing with or with out the list() wrapper. Using
>> Python 3.4.0 (default, Apr 11 2014, 13:05:11)
>> [GCC 4.8.2] on linux
>
> I don't think so. Perhaps you need to look a little more closely?
>
> py> grid = [(1,2), (3,4), (5,6)]
> py> zip(*grid)
> <zip object at 0xb7bf238c>
> py> list(zip(*grid))
> [(1, 3, 5), (2, 4, 6)]
>
> Zip objects are not lists, although they can often (but not always) be
> used where you are expecting a list.
>
>
Yes, you are correct. I was to naive, the result of both work the same 
in my code. But they are of different types.


More information about the Tutor mailing list