Python: Converting a queryset in a list of tuples
<p>i want to turn a queryset into a list of tuples. "result" ist what it should look like:</p>

<pre><code>queryset = [{x:'1',y:'a'}, {x:'2',y:'b'}]
result = [(1,'a'),(2,'b')]
</code></pre>

<p>So the solution i do have right now is this one, but it seems to me that there could be a way to shorten the code, and make it more efficient. Is there a way?</p>

<p>My current solution:</p>

<pre><code>result = []
for dic in queryset:
    result.append((dic[x],dic[y]))
</code></pre>

<p>You can use <code>dict.values()</code>:</p>

<pre><code>queryset = [{x:'1',y:'a'}, {x:'2',y:'b'}]
result = []

for i in queryset:
    result.append(tuple(i.values()))
</code></pre>

<p>Or in one line:</p>

<pre><code>result = [tuple(i.values()) for i in queryset]
</code></pre>

<hr>

<p>If you want them in a particular order:</p>

<p><code>result = [(i[x], i[y]) for i in queryset]</code></p>

python django performance