Skip to content

Commit 657be6b

Browse files
committed
Optimize and fix bug in container output.
1 parent 698b015 commit 657be6b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Compiler/library.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ def print_plain_str(ss):
106106
raise CompilerError('Cannot print secret value:', args[i])
107107
elif isinstance(val, cfloat):
108108
val.print_float_plain()
109-
elif isinstance(val, (list, tuple, Array, SubMultiArray)):
109+
elif isinstance(val, (list, tuple)):
110110
print_str(*_expand_to_print(val), print_secrets=print_secrets)
111+
elif isinstance(val, (Array, SubMultiArray)):
112+
val.output(print_secrets=print_secrets)
111113
else:
112114
try:
113115
val.output()

Compiler/types.py

+13
Original file line numberDiff line numberDiff line change
@@ -6415,6 +6415,12 @@ def _(i):
64156415
library.print_str('%s', self[self.length - 1].reveal())
64166416
library.print_str(']' + end)
64176417

6418+
def output(self, **kwargs):
6419+
try:
6420+
library.print_str('%s', self[:], **kwargs)
6421+
except:
6422+
MultiArray.output(self, **kwargs)
6423+
64186424
def reveal_to_binary_output(self, player=None):
64196425
""" Reveal to binary output if supported by type.
64206426
@@ -7392,6 +7398,13 @@ def _(i):
73927398
self[len(self) - 1].print_reveal_nested(end='')
73937399
library.print_str(']' + end)
73947400

7401+
def output(self, **kwargs):
7402+
library.print_str('[')
7403+
@library.for_range(len(self) - 1)
7404+
def _(i):
7405+
library.print_str('%s, ', self[i], **kwargs)
7406+
library.print_str('%s]', self[len(self) - 1], **kwargs)
7407+
73957408
def reveal_to_binary_output(self, player=None):
73967409
""" Reveal to binary output if supported by type.
73977410

0 commit comments

Comments
 (0)