So I have a set of points in a city (say houses or residences) and I want to find the shortest distance between these points and a set of candidate points for a store. I am looking for the best store locations that will minimize the distance to all of the houses in the set. So I will iteratively move the candidate store points and then recompute the distances between each store and house (again using Djikstra's algorithm). Because of the sheer volume of calculations, I cannot keep hitting the database for each iteration of the optimization algorithm.
I have used pgrouting many times and this would work, however it would be too slow because of the large number of points and the fact that it has to search the disk each time. 
Is there a tool where I an load some small Open Street Maps city map in memory and then calculate the shortest routes in memory? I would need something fast, so preferably in C or python? But any language is okay as long as it works.
Heres and idea. Get the latlongs of the house and all the stores. 
Calculate the geohash of all points(house and stores) with maximum precision (12) and check if geohash of any stores matches that of the house. If it doesnt, calculate the geohash with lower precision (11) and then rinse and repeat till you get a store(May be multiple Ill get into that later) that matches the geohash of the house.
This is a fuzzy-distance calculation. This will work great and with minimal processing time. But this will fail if you get two or more stores with the same geohash with some precision. So this is what I recommend you do 

The geohash loop with decreasing precision. Break when geohash of store(s) match the gohash of the house
IF (more than one sores match) Go for plain distance calculation and find the closest store and return it
ELSE return the one store that the matches the geohash

Advantage of this method : Changes your strict requirements to a fuzzy probability problem. If you get a single sore, great. If you dont at least you reduce the number of candidates for distance calculation
Disadvantage of this method: What if all stores land in the same geohash ? We introduce the same complexity here.
Youll be banking on the chances that not all(or most) stores come under the same geohash. Realistically speaking, the disadvantage is only a disadvantage in corner cases. So overall you should soo performance improvement
Way to calculate road distances in a city very quickly