you say the code takes 0.3 seconds. Is this the algorithm or the overhead that you are trying to eliminate. If that is the algorithm, rewriting in a different framework will not help you. If that is the overhead, that is definitively too much. Probably you are executing something that should not be executed, for example the models.
Hard to say without looking at the code.
Based on my experience, the web2py overhead without models is ~5-10ms. This is because of cookie parsing, client headers validation, session handling, and checking the file system for models. If you do not need any of this and you need sub ms performance, I'd recommend bare bone tornado or gevent. You do not need a framework.
Massimo