Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将多个参数或字典传递给延迟函数(deferred.defer/pickle)?_Python_Google App Engine_Pickle - Fatal编程技术网

Python 将多个参数或字典传递给延迟函数(deferred.defer/pickle)?

Python 将多个参数或字典传递给延迟函数(deferred.defer/pickle)?,python,google-app-engine,pickle,Python,Google App Engine,Pickle,知道延迟的任务一天会被调用数千次,以下两种方法(在使用Google App Engine的带宽和cpu方面)有什么更好的选择 我猜参数的处理方式会有所不同,POST请求的大小以及延迟调用的持续时间都会受到影响 第一种方法: from google.appengine.ext import deferred def do_something_later(string1, string2, string3, string4): template_values = { 'st

知道延迟的任务一天会被调用数千次,以下两种方法(在使用Google App Engine的带宽和cpu方面)有什么更好的选择

我猜参数的处理方式会有所不同,POST请求的大小以及延迟调用的持续时间都会受到影响

第一种方法:

from google.appengine.ext import deferred

def do_something_later(string1, string2, string3, string4):
    template_values = {
        'stuff': string1,
        'specs': string2,
        'misc1': string3,
        'misc2': string4,
    }
    # do something with template_values

deferred.defer(do_something_later, string1, string2, string3, string4)
from google.appengine.ext import deferred

def do_something_later(template_values):
    # do something with template_values

template_values = {
    'stuff': string1,
    'specs': string2,
    'misc1': string3,
    'misc2': string4,
}
deferred.defer(do_something_later, template_values)
第二种方法:

from google.appengine.ext import deferred

def do_something_later(string1, string2, string3, string4):
    template_values = {
        'stuff': string1,
        'specs': string2,
        'misc1': string3,
        'misc2': string4,
    }
    # do something with template_values

deferred.defer(do_something_later, string1, string2, string3, string4)
from google.appengine.ext import deferred

def do_something_later(template_values):
    # do something with template_values

template_values = {
    'stuff': string1,
    'specs': string2,
    'misc1': string3,
    'misc2': string4,
}
deferred.defer(do_something_later, template_values)

我无法想象在什么情况下这会有什么不同。第一个选项和第二个选项之间的大小差异仅为几个字节。即使每天运行数千次,在这段时间内,您也只需要说几Kb。这真的不值得操心。您应该使用对您的代码更有意义的选项。

有关于引擎盖下的不同之处的信息吗?