Re: [Django] #15648: [Feature request] NamedTupleQuerySet

2013-11-19 Thread Django
#15648: [Feature request] NamedTupleQuerySet
-+-
 Reporter:  pbagwl   |Owner:  paulmillr
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:  namedtuple, tuple,   |  Needs documentation:  1
  queryset   |  Patch needs improvement:  1
Has patch:  1|UI/UX:  0
  Needs tests:  0|
Easy pickings:  0|
-+-

Comment (by suprzer0@…):

 Perhaps adding a keyword argument to values_list() for namedtuples?
 something like
 {{{
 #!python
 Item.objects.values_list(*names_list, named=True)
 }}}
 With named defaulting to False.

 Calling .values_list(*names_list, named=True, flat=True) would need to
 throw some kind of exception I'd imagine.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.ea54c2bd4d51cbf0f9ff5e35ede13ea2%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Django] #15648: [Feature request] NamedTupleQuerySet

2013-01-04 Thread Django
#15648: [Feature request] NamedTupleQuerySet
-+-
 Reporter:  pbagwl   |Owner:  paulmillr
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:  namedtuple, tuple,   |  Needs documentation:  1
  queryset   |  Patch needs improvement:  1
Has patch:  1|UI/UX:  0
  Needs tests:  0|
Easy pickings:  0|
-+-

Comment (by anonymous):

 This would be really, really nice.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #15648: [Feature request] NamedTupleQuerySet

2012-04-02 Thread Django
#15648: [Feature request] NamedTupleQuerySet
-+-
 Reporter:  pbagwl   |Owner:  paulmillr
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  SVN
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:  namedtuple, tuple,   |  Needs documentation:  1
  queryset   |  Patch needs improvement:  1
Has patch:  1|UI/UX:  0
  Needs tests:  0|
Easy pickings:  0|
-+-

Comment (by akaariai):

 I have a very quick implementation of returning namedtuples from
 .values_list(). The patch seems to be backwards compatible, that is, all
 tests pass.

 The performance penalty seems to be about 20% for one-field values_list()
 call. It is a good question if that is acceptable. I guess yes as
 namedtuples are _much_ nicer than regular tuples. On the other hand the
 main use case for values_list is performance.

 The results are using SQLite to fetch 200 objects with one field
 containing a four char value, and then additional fields containing NULLs.
 values_list with one field gives the 20% performance penalty, 5 fields
 gives 15% penalty. Notably in-memory SQLite with fields containing
 practically no data is pretty much the worst-case. I guess the real-world
 penalty will be in 5%-20% range depending on use case. My opinion is that
 getting namedtuples is worth it.

 I guess similar performance penalty would be paid if cursors were to
 return named tuples directly, and that is even tougher call to make.
 Cursors are even more performance critical, and every query made by Django
 would need to pay the penalty. Although when creating model instance for
 example that penalty would be hidden by overhead of `model.__init__`.

 It is of course possible to add the .namedtuples() API, but then we have
 three things doing nearly the same thing, and two doing exactly the same
 thing from user perspective.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15648: [Feature request] NamedTupleQuerySet

2012-04-02 Thread Django
#15648: [Feature request] NamedTupleQuerySet
-+-
 Reporter:  pbagwl   |Owner:  paulmillr
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  SVN
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:  namedtuple, tuple,   |  Needs documentation:  1
  queryset   |  Patch needs improvement:  1
Has patch:  1|UI/UX:  0
  Needs tests:  0|
Easy pickings:  0|
-+-

Comment (by akaariai):

 Why the namedtuples API? Is there some reason values_list should not
 return namedtuples directly? It should be backwards compatible, as index
 based fetching still work. I believe there will not be any serious
 performance impact.

 If the performance is acceptable, then raw cursors should return named
 tuples, too. That would be a really nice addition for raw SQL users. But
 of course, this is another ticket's problem.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15648: [Feature request] NamedTupleQuerySet

2011-08-12 Thread Django
#15648: [Feature request] NamedTupleQuerySet
-+-
   Reporter:  pbagwl |  Owner:  paulmillr
   Type:  New| Status:  assigned
  feature|  Component:  Database layer
  Milestone:  1.4|  (models, ORM)
Version:  SVN|   Severity:  Normal
 Resolution: |   Keywords:  namedtuple, tuple,
   Triage Stage:  Accepted   |  queryset
Needs documentation:  1  |  Has patch:  1
Patch needs improvement:  1  |Needs tests:  0
  UI/UX:  0  |  Easy pickings:  0
-+-
Changes (by jezdez):

 * needs_docs:  0 => 1
 * needs_better_patch:  0 => 1
 * stage:  Ready for checkin => Accepted


Comment:

 This definitely isn't ready for checkin yet as there are no docs.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15648: [Feature request] NamedTupleQuerySet

2011-08-12 Thread Django
#15648: [Feature request] NamedTupleQuerySet
-+-
   Reporter:  pbagwl |  Owner:  paulmillr
   Type:  New| Status:  assigned
  feature|  Component:  Database layer
  Milestone:  1.4|  (models, ORM)
Version:  SVN|   Severity:  Normal
 Resolution: |   Keywords:  namedtuple, tuple,
   Triage Stage:  Ready for  |  queryset
  checkin|  Has patch:  1
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
Changes (by paulmillr):

 * stage:  Accepted => Ready for checkin


Comment:

 I don't know much about ticket triaging, but I think that «ready for
 checkin» would be more correct for this

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15648: [Feature request] NamedTupleQuerySet

2011-06-29 Thread Django
#15648: [Feature request] NamedTupleQuerySet
-+-
   Reporter:  pbagwl |  Owner:  paulmillr
   Type:  New| Status:  assigned
  feature|  Component:  Database layer
  Milestone:  1.4|  (models, ORM)
Version:  SVN|   Severity:  Normal
 Resolution: |   Keywords:  namedtuple, tuple,
   Triage Stage:  Accepted   |  queryset
Needs documentation:  0  |  Has patch:  1
Patch needs improvement:  0  |Needs tests:  0
  UI/UX:  0  |  Easy pickings:  0
-+-
Changes (by paulmillr):

 * owner:  nobody => paulmillr
 * status:  new => assigned


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15648: [Feature request] NamedTupleQuerySet

2011-06-28 Thread Django
#15648: [Feature request] NamedTupleQuerySet
-+-
   Reporter:  pbagwl |  Owner:  nobody
   Type:  New| Status:  new
  feature|  Component:  Database layer
  Milestone:  1.4|  (models, ORM)
Version:  SVN|   Severity:  Normal
 Resolution: |   Keywords:  namedtuple, tuple,
   Triage Stage:  Accepted   |  queryset
Needs documentation:  0  |  Has patch:  1
Patch needs improvement:  0  |Needs tests:  0
  UI/UX:  0  |  Easy pickings:  0
-+-
Changes (by Paul Miller ):

 * cc: paulmillr@… (added)
 * needs_better_patch:  1 => 0
 * ui_ux:   => 0
 * needs_tests:  1 => 0
 * needs_docs:  1 => 0


Comment:

 I've added necessary tests and fallback implementation for Python 2.5
 users.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15648: [Feature request] NamedTupleQuerySet

2011-05-22 Thread Django
#15648: [Feature request] NamedTupleQuerySet
-+-
   Reporter:  pbagwl |  Owner:  nobody
   Type:  New| Status:  new
  feature|  Component:  Database layer
  Milestone:  1.4|  (models, ORM)
Version:  SVN|   Severity:  Normal
 Resolution: |   Keywords:  namedtuple, tuple,
   Triage Stage:  Accepted   |  queryset
Needs documentation:  1  |  Has patch:  1
Patch needs improvement:  1  |Needs tests:  1
 |  Easy pickings:  0
-+-
Changes (by ShawnMilo):

 * cc: ShawnMilo (added)


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15648: [Feature request] NamedTupleQuerySet

2011-05-22 Thread Django
#15648: [Feature request] NamedTupleQuerySet
-+-
   Reporter:  pbagwl |  Owner:  nobody
   Type:  New| Status:  new
  feature|  Component:  Database layer
  Milestone:  1.4|  (models, ORM)
Version:  SVN|   Severity:  Normal
 Resolution: |   Keywords:  namedtuple, tuple,
   Triage Stage:  Accepted   |  queryset
Needs documentation:  1  |  Has patch:  1
Patch needs improvement:  1  |Needs tests:  1
 |  Easy pickings:  0
-+-
Changes (by d0ugal):

 * cc: dougal85@… (added)
 * needs_docs:  0 => 1
 * easy:   => 0


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15648: [Feature request] NamedTupleQuerySet

2011-04-02 Thread Django
#15648: [Feature request] NamedTupleQuerySet
-+-
   Reporter:  pbagwl |Owner:  nobody
   Type:  New|   Status:  new
  feature|Component:  Database layer
  Milestone:  1.4|  (models, ORM)
Version:  SVN| Severity:  Normal
 Resolution: | Keywords:  namedtuple, tuple,
   Triage Stage:  Accepted   |  queryset
Needs documentation:  0  |Has patch:  1
Patch needs improvement:  1  |  Needs tests:  1
-+-
Changes (by EnTeQuAk):

 * cc: cg@… (added)


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15648: [Feature request] NamedTupleQuerySet

2011-03-25 Thread Django
#15648: [Feature request] NamedTupleQuerySet
-+-
   Reporter:  pbagwl |Owner:  nobody
 Status:  new|Milestone:  1.4
  Component:  Database   |  Version:  SVN
  layer (models, ORM)| Keywords:  namedtuple, tuple,
 Resolution: |  queryset
   Triage Stage:  Accepted   |Has patch:  1
Needs documentation:  0  |  Needs tests:  1
Patch needs improvement:  1  |
-+-
Changes (by adrian):

 * needs_better_patch:  0 => 1
 * needs_tests:  0 => 1
 * stage:  Unreviewed => Accepted


Comment:

 I like the idea of introducing a {{{QuerySet}}} that returns named tuples!
 Not crazy about the name, but I can't think of a better one at the moment.

 Can you create an actual .patch file, include unit tests and include a
 fallback namedtuple implementation for our Python 2.4/2.5 users? A good
 place for that would be in {{{django/utils/datastructures.py}}}.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15648: [Feature request] NamedTupleQuerySet

2011-03-21 Thread Django
#15648: [Feature request] NamedTupleQuerySet
-+-
   Reporter:  pbagwl |Owner:  nobody
 Status:  new|Milestone:  1.4
  Component:  Database   |  Version:  SVN
  layer (models, ORM)| Keywords:  namedtuple, tuple,
 Resolution: |  queryset
   Triage Stage: |Has patch:  1
  Unreviewed |  Needs tests:  0
Needs documentation:  0  |
Patch needs improvement:  0  |
-+-

Comment (by pbagwl):

 Replying to [comment:2 me@…]:
 > Why not
 > {{{
 > Item.objects.all().only(*names_list)
 > }}}
 > ?

 1. repr(). values / values lists etc. are much easier to debug.
 2. deferred objects (only creates them) are not iterables

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15648: [Feature request] NamedTupleQuerySet

2011-03-20 Thread Django
#15648: [Feature request] NamedTupleQuerySet
-+-
   Reporter:  pbagwl |Owner:  nobody
 Status:  new|Milestone:  1.4
  Component:  Database   |  Version:  SVN
  layer (models, ORM)| Keywords:  namedtuple, tuple,
 Resolution: |  queryset
   Triage Stage: |Has patch:  1
  Unreviewed |  Needs tests:  0
Needs documentation:  0  |
Patch needs improvement:  0  |
-+-

Comment (by me@…):

 Why not
 {{{
 Item.objects.all().only(*names_list)
 }}}
 ?

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15648: [Feature request] NamedTupleQuerySet

2011-03-19 Thread Django
#15648: [Feature request] NamedTupleQuerySet
-+-
   Reporter:  pbagwl |Owner:  nobody
 Status:  new|Milestone:  1.4
  Component:  Database   |  Version:  SVN
  layer (models, ORM)| Keywords:  namedtuple, tuple,
 Resolution: |  queryset
   Triage Stage: |Has patch:  1
  Unreviewed |  Needs tests:  0
Needs documentation:  0  |
Patch needs improvement:  0  |
-+-
Changes (by kmike):

 * cc: kmike84@… (added)
 * needs_docs:   => 0
 * needs_tests:   => 0
 * needs_better_patch:   => 0


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



[Django] #15648: [Feature request] NamedTupleQuerySet

2011-03-19 Thread Django
#15648: [Feature request] NamedTupleQuerySet
--+---
 Reporter:  pbagwl| Owner:  nobody
   Status:  new   | Milestone:  1.4
Component:  Database layer (models, ORM)  |   Version:  SVN
 Keywords:  namedtuple, tuple, queryset   |  Triage Stage:  Unreviewed
Has patch:  1 |
--+---
 Python 2.6 supports named tuples. Information about field names is stored
 in the tuple class, so there's no overhead like in dictionaries.
 I propose to use them in querysets instead of values() / values_list().

 {{{#!python
 qs = Items.objects.filter(...).namedtuples('title', 'amount', 'price')
 for item in qs:
 print item.title, item.amount
 total += item.amount * item.price
 }}}

 Patch:

 {{{#!python
 from itertools import imap
 from collections import namedtuple

 # python 2.5 doesn't support named tuples, so we can use this
 http://code.activestate.com/recipes/500261/

 from django.db.models.query import ValuesQuerySet

 class NamedTuplesQuerySet(ValuesQuerySet):
 def iterator(self):
 # get field names
 extra_names = self.query.extra_select.keys()
 field_names = self.field_names
 aggregate_names = self.query.aggregate_select.keys()
 names = extra_names + field_names + aggregate_names

 # create named tuple class
 tuple_cls = namedtuple('%sTuple' % self.model.__name__, names)

 results_iter = self.query.get_compiler(self.db).results_iter()
 # wrap every string with our named tuple
 return imap(tuple_cls._make, results_iter)
 }}}

 {{{#!python
 from django.db.models.query import QuerySet

 def namedtuples(self, *fields):
 return self._clone(klass=NamedTuplesQuerySet, setup=True,
 _fields=fields)
 QuerySet.namedtuples = namedtuples
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.