The _one_shot was recently removed. Is there an another way to disable use of c_make_encoder at runtime?
The only idea I have is it to disable it globally with simplejson.encoder.c_make_encoder = None but then it's always disabled and that is not perfect either.
That option allowed to use generators and stream json output without allocating too much memory.
import types
import simplejson
def gen():
yield 1
yield 2
yield 3
encoder = simplejson.JSONEncoder(iterable_as_array=True)
output = encoder.iterencode(gen(), _one_shot=False)
assert isinstance(output, types.GeneratorType)
print(''.join(output))
The
_one_shotwas recently removed. Is there an another way to disable use ofc_make_encoderat runtime?The only idea I have is it to disable it globally with
simplejson.encoder.c_make_encoder = Nonebut then it's always disabled and that is not perfect either.That option allowed to use generators and stream json output without allocating too much memory.