Skip to content

Commit

Permalink
avoid creating elements_properties when not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatera committed Jun 26, 2022
1 parent 90bca63 commit 5f57c63
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions mathics/core/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ def __init__(
self._head = head
self._elements = elements
self.elements_properties = elements_properties
if elements_properties is None:
self._build_elements_properties()
# if elements_properties is None:
# self._build_elements_properties()

self._sequences = None
self._cache = None
Expand Down Expand Up @@ -1046,13 +1046,13 @@ def rest_range(indices):
# FIXME: see if we can preserve elements properties in eval_elements()
recompute_properties = eval_elements()

new = Expression(
head,
*elements,
elements_properties=None
if recompute_properties
else self.elements_properties
)
if recompute_properties:
new = Expression(head, *elements, elements_properties=None)
new._build_elements_properties()
else:
new = Expression(
head, *elements, elements_properties=self.elements_properties
)

# Step 3: Now, process the attributes of head
# If there are sequence, flatten them if the attributes allow it.
Expand Down

0 comments on commit 5f57c63

Please sign in to comment.