Python

Apr 14, 2010 01:24

App Engine kind of rocks if you use the Python version. The JVM version, which is what you're stuck with if you want to use Ruby, isn't even good enough to suck. It isn't even "beta" or "testing". It's a complete joke. It takes 13-20 seconds to warm up, and it cools down after a few minutes of not being used. That renders it completely useless ( Read more... )

Leave a comment

Comments 10

maharishi April 14 2010, 22:28:02 UTC
Guido himself has this to say: http://neopythonic.blogspot.com/2008/10/why-explicit-self-has-to-stay.html

There's a pretty good argument to make that requiring explicit 'self' in the parameter list reinforces the theoretical equivalency between these two ways of calling a method, given that 'foo' is an instance of 'C':

foo.meth(arg) == C.meth(foo, arg)

It's neat to know that that's how it works, but unless I'm missing something, his argument has nothing to it. Under the hood, methods are invoked with Class.method(object, argument), but we're allowed a little syntactic sugar, so that we can normally invoke them with object.method(argument). If he's willing to do that, the question remains: why isn't he willing to let

Class C
def method(argument): passjust be syntactic sugar for what under the hood is interpreted as a method that takes two arguments, the first of which normally gets passed automatically, but which you can ( ... )

Reply


daniel_t_miles April 14 2010, 23:19:45 UTC
The next thing that's going to piss you off is inheritance. If you recall from your object oriented theory that an instance of class B where B is a child of class A inherits all the methods and properties from class A. In C++, the way this is done is to make B actually contain a semi-hidden instance of A. Python does things the same way. But, like the "you have to pass self all over the place" decision, it's not exactly hidden. It looks like this.

class A:
def __init__(self, var):
self.Avar = var
def foo():
print self.Avar
class B(A): # that's how you say it sub-classes A
def __init__(self, var):
A.__init__(self, var + 1)
self.Bvar = var
def bar():
print self.Bvar

obj = B(5)
obj.foo()
obj.bar()

results in:

6
5

After that, the next thing that's going to piss you off is that the function to assemble a string from a list is a function in the string class, not the list.

l = ["foo", "bar", "foobar"]
print "\n".join(l)

results in:
foo
bar
foobar

Reply

jes5199 April 15 2010, 00:29:14 UTC
somehow, neither of those look all that weird to me.

Reply

keturn April 15 2010, 07:18:21 UTC
I still think the ''.join(l) idiom is weird.

Reply

maharishi April 15 2010, 00:32:16 UTC
So A.__init__(self, ...) is the equivalent of Ruby's super(...). I can live with that. Actually, since Python has multiple inheritance, you would need to state which superclass you want, so that makes sense, I think. Or am I missing the detail I'm likely to find annoying?

join being part of String rather than Array does seem backwards coming from Ruby, but I can see the sense in it.

I expect going in that most of the little things will work differently than I'm used to. Having to explicitly write all member functions to receive the calling object as the first parameter isn't something that I expect in a high-level language that's heard of object-orientation, though.

Reply


(The comment has been removed)

maharishi April 14 2010, 23:54:20 UTC
I've heard complaints that it's slower than it used to be. A plain JVM with no libraries, just a line of Java that prints "Hi" or something, takes 5-10 seconds when I've tried it a few times over the past week or two. JRuby is what pushes it to 13-20s. I should have been clearer about that, but I was busy ranting. Either way, that's way too long. The python version takes 65-100ms on a cold start, and then 6-21ms once it's up. Once JRuby's up, it's a very reasonable 35-75ms.

I was considering Duby (Ruby syntax that compiles to Java bytecode; I'd miss the dynamic/magic nature of Ruby, but at least I'd have my syntax), but when I realized I'd still be waiting at least 5 seconds for it to fire up, I realized Python is the only option.

Reply


keturn April 15 2010, 07:08:15 UTC

A) You do seem stressed out lately. Getting confused and frustrated over design choices of "free" web services in order to save yourself a few dollars a week isn't like you. Take care of yourself.

B) explicit self is a symptom of one of my favorite things about Python, which is identifiers are always explicitly defined in the file where they are used. For any identifier, I can always use the text editor's plain "find string in file" function and find it in an import statement, an assignment statement, class or def statement, or the function signature. I could understand if self were an exception to this, but I don't mind that it's not.

Having all function arguments be explicit also lets you do this, although I'll leave it to you to debate the merits of that.

3) I'm not sure I understood you correctly, but if you really are just hosting static content (perhaps generating it with something like Jekyll), price it out with NearlyFreeSpeech. Be sure to check the "only static content" option and set mysql processes to 0. I host ( ... )

Reply

maharishi April 15 2010, 10:17:15 UTC
My response got really long, so I posted it as an entry, here.

Reply


Leave a comment

Up