(Note: this applies to any version of TiddlyWiki new and old; however, I do not take into consideration or use features in TiddlyWiki beyond version 5.2.3 as they really are of no interest to me.)
In terms of TiddlyWiki:
A Cartesian product is the result of cycling through every item in a list with every item in the very same list (or any other list) .
To understand that, let’s consider a scenario: producing a list in which a “horizontal rule” is placed after every item except for the last one.
Now let’s look at this TW script:
<$list filter="[tag[Articles]] +[sort[]]">
<h2><$link><$view field="title"/></$link></h2>
<$transclude mode="block" field="text"/>
<$list filter="[tag[Articles]] +[sort[]] +[last[]] +[!match<currentTiddler>]"><hr></$list>
</$list>
Let’s pretend that the outer list will result in 50 items.
The inner list gets the same list of 50 items to find out if the current outer list item is the last item.
The cartesian product = 50 times 50 = 2,500. That is the number of items that get processed in total.
In general, this may not matter because TiddlyWiki is blazingly fast.
However, we run the risk of running into that once in a blue moon moment in which something time-consuming is going to happen 2,500 times. That’s bad.
The best way to get around this problem is to rethink things.
Finding out what is the last item in the list involves creating the list entirely and then getting the last item.
Same thing getting the first item in a list: still involves creating the list entirely and then getting the first item.
If we dive into the list widget, we can setup a counter variable. Taking advantage of that, and rejigging the process a little, we can do this:
<$list filter="[tag[Articles]] +[sort[]]" counter="myCounter">
<$list filter="[<myCounter>!match[1]]"><hr></$list>
<h2><$link><$view field="title"/></$link></h2>
<$transclude mode="block" field="text"/>
</$list>
Now, for every item in the outer list, the stuff inside the list happens 50 times (pretending we are dealing with 50 items in the list).
The inner list, however, will only ever produce one item each of those 50 times.
So the result is 50 (items in the outer list) + 1 items (in the inner list) 50 times (one time for each item in the outer list) = 50 + 50 = 100 items processed in total.
Going from 2,500 items getting processed to 100 items getting processed, that’s 25 times less processing going on. In some scenarios, that could be a big deal.