Skip to content

Commit

Permalink
Reduce the calls to python's upper()
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Smith committed Nov 28, 2014
1 parent 83afd2b commit 6b50ca9
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,26 +245,19 @@ class PriceEntry(namedtuple('PriceEntry', [
def getSystemByNameIndex(cur):
""" Build station index in STAR/Station notation """
cur.execute("""
SELECT station_id, system.name, station.name
SELECT station_id,
UPPER(system.name) || '/' || UPPER(station.name)
FROM System
INNER JOIN Station
ON System.system_id = Station.system_id
USING (system_id)
""")
return {
"{}/{}".format(sysName.upper(), stnName.upper()): ID
for (ID, sysName, stnName)
in cur
}
return { name: ID for (ID, name) in cur }


def getCategoriesByNameIndex(cur):
""" Build category name => id index """
cur.execute("SELECT category_id, name FROM category")
return {
name: ID
for (ID, name)
in cur
}
return { name: ID for (ID, name) in cur }


def testItemNamesUniqueAcrossCategories(cur):
Expand Down

0 comments on commit 6b50ca9

Please sign in to comment.