# ClearAttributes in ParallelDo

The following code

ClearAttributes[Times, Orderless];
temp = b*a;
Do[
Print[temp];, {i, 1}
]


will print

b*a


However, the following code

ClearAttributes[Times, Orderless];
temp = b*a;
ParallelDo[
Print[temp];, {i, 1}
]


will print

a*b


My understanding is that the ClearAttributes is only working on the current kernel before the parallel kernels are created. Thus, the parallel kernels have not had their Times cleared of the Orderless attribute. Is there a way to keep the Orderless attribute for Times cleared in the ParallelDo without putting the line

ClearAttributes[Times, Orderless];


in the ParallelDo loop?

• Why is there even a need to do ClearAttributes[Times, Orderless]? – J. M. will be back soon Sep 25 '18 at 18:43
• I'm trying to simplify a messy expression that utilizes NonCommutativeMultiply. I'm removing the Orderless attribute so that I can thread NonCommutativeMultiply over Times for use later during the simplification without the Orderless attribute changing the order of how I defined my variables. I'm not sure if there is a better way to do that. – D W Sep 25 '18 at 18:53
• If your "product" isn't actually commutative, and NonCommutativeMultiply[] is already in use, you can use e.g. CircleTimes[] as a dummy operator, which won't autosort the factors. – J. M. will be back soon Sep 25 '18 at 18:58