def __new__(cls, filename=None, *args, **kwargs):
if not isinstance(filename, string_types):
obj = object.__new__(cls)
# The Stream frontend uses a StreamHandler object to pass metadata
# to __init__.
is_stream = (hasattr(filename, 'get_fields') and
hasattr(filename, 'get_particle_type'))
if not is_stream:
obj.__init__(filename, *args, **kwargs)
return obj
apath = os.path.abspath(filename)
cache_key = (apath, cPickle.dumps(args), cPickle.dumps(kwargs))
if ytcfg.getboolean("yt","skip_dataset_cache"):
obj = object.__new__(cls)
elif cache_key not in _cached_datasets:
obj = object.__new__(cls)
if obj._skip_cache is False:
_cached_datasets[cache_key] = obj
else:
obj = _cached_datasets[cache_key]
return obj
评论列表
文章目录