Is there any efficient way to generating the non-associative binary products ?

Yes, it should definitely be possible to improve the speed of your Julia code. However, it will be much easier to help you if you can follow the directions here: PSA: how to quote code with backticks so that your code will be more readable. You should also take a look at the general Julia performance tips: Performance Tips · The Julia Language and in particular the section about avoiding fields with abstract type, which is a problem with your current code: Performance Tips · The Julia Language