My app requires an often-repeating procedure where I need to take two
separate values, and choose one of them.

For example:

class Item():
     day
     player = [red, black]
     value

I need to select which value is larger, and then apply a point to
either Reds or Blacks.  Which approach is more efficient

Option one:  perform two queries to get red and black separately, then
compare them:

  red = models.Item.all().filter('day =', day).filter('player =',
red).get()
  black = models.Item.all().filter('day =', day).filter('player =',
black).get()
  if red.value>black.value:
      Reds += 1
  else
     Blacks += 1

Option two:  perform one query to get both values, sort them, then
compare them:

  items = models.Item.all().filter('day =', day).fetch(2)
  for item in items:
    if item.player == 'red':
       red = item
    else:
       black = item
  if red.value>black.value:
      Reds += 1
  else
     Blacks += 1

Basically, since I need to repeat this kind of an action very often,
it's worth knowing which is the better approach.  Thanks!









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

Reply via email to