Just assume that any string/list/hash/integer-related operations in
Python are likely faster than you'll ever need them to be. The
overhead for buffering the response is going to be tiny regardless of
your application, since at most you're only talking about handling
strings of up to 10mb (which is the request size limit).

If there is anything with AppEngine you need to be careful of, it is
use of Datastore, where reading/writing large numbers of entities will
cost a lot of performance. Reducing your Datastore use by a single
db.get() is equal to thousands of calls to self.response.out.write()

$ python /usr/lib/python2.5/timeit.py -v -s 'from cStringIO import
StringIO; out = StringIO()'  'out.write("123")'
10000 loops -> 0.00373 secs
100000 loops -> 0.0383 secs
1000000 loops -> 0.365 secs
raw times: 0.358 0.358 0.357
1000000 loops, best of 3: 0.357 usec per loop

$ ae
Python 2.5.1 (r251:54863, Feb  6 2009, 19:02:12)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(AppEngineShell)
>>> import time
>>> t1 = time.time() ; db.get(db.Key.from_path('Foo', 1234)) ; print 
>>> (time.time()-t1)*1000
12.0000839233


David.

2009/5/29 Shedokan <shedok...@gmail.com>:
>
> Thanks, but does self.response.out affects speed very much?
> I couldn't benchmark it, strange...
>
>
> On 28 מאי, 22:25, David Wilson <d...@botanicus.net> wrote:
>> Using self.response.out will also delay sending your entire response
>> until it is sure to succeed.
>>
>> If you start generating output using 'print', and then e.g. a
>> Datastore request times out, or a bug in your code is triggered, you
>> have no chance to display a friendly error message. Instead the user
>> will get a half-rendered page with a stack trace embedded in it, or
>> worse.
>>
>> David.
>>
>> 2009/5/28 Shedokan <shedok...@gmail.com>:
>>
>>
>>
>>
>>
>>
>>
>> > so I can't print binary data like Images?
>>
>> > On 28 מאי, 21:03, 风笑雪 <kea...@gmail.com> wrote:
>> >> Print is also OK, but you need handle header by yourself, and it can only
>> >> output 
>> >> text.http://code.google.com/intl/en/appengine/docs/python/gettingstarted/h...
>>
>> >> print 'Content-Type: text/plain'
>> >> print ''
>> >> print 'Hello, world!'
>>
>> >> 2009/5/29 Shedokan <shedok...@gmail.com>
>>
>> >> > I am wondering why should I use self.response.out.write and not print
>> >> > everything.
>>
>> >> > because I am making this app where I have to output from a lot
>> >> > ofdifferent functions and I am passing the object 'self' everywhere.
>>
>> >> > thanks.
>>
>> --
>> It is better to be wrong than to be vague.
>>   — Freeman Dyson
> >
>



-- 
It is better to be wrong than to be vague.
  — Freeman Dyson

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to