将Python与更快的语言混合以在GAE中进行优化

问题描述:

I'm a newbie in the Python and GAE world and I have a question. With Python the normal approach is to only optimize the code when needed, fixing the more urgent bottlenecks. And one of the ways to achieve that is by rewriting the most critical parts of the program in C.

By using GAE are we losing this possibility forever? Since Google's Go language is now (or it will be as soon as it is compiled more efficiently) the fastest language in GAE, will there be a way to mix Python and Go in the same app? What other ways could be used to achieve a similar result?

我是Python和GAE领域的新手,我有一个问题。 使用Python,通常的方法是 仅在需要时优化代码,解决更紧急的瓶颈。 实现此目标的方法之一是用C重写程序中最关键的部分。 p>

通过使用GAE 我们会永远失去这种可能性吗? 因为 Google的Go语言现在已经存在(或者它将在编译后尽快出现) 高效)是GAE中最快的语言,是否有一种方法可以在同一应用程序中混合使用Python和Go? 还有什么其他方法可以实现相似的结果? p> div>

See Can I write parts of the Google App Engine code in Java, other parts in Python? for how to use multiple languages.

Basically, each version of a given app can only use one runtime language.

But, you can have two different versions of your app, written in different languages, and they can pass information back and forth through the datastore.

Also, you can have two different apps, in two different languages, and you can have then pass information back and forth through requests.

I think you're falling for premature optimisation here. For nearly all webapps, the majority of time spent is in RPCs, waiting for the rest of the system to do something such as process datastore queries. Of the remainder, a significant fraction is often spent in C code anyway. There are relatively few webapps that need to do a lot of processor-intensive work in order to serve a typical query.

If your app is one of those, you may want to reconsider writing your entire app in Python, given the unavailability of C extensions on App Engine, and choose Java or Go. If your app is one of the 99% that don't need to do much processor intensive work for typical requests, don't worry about it.