Unexpected results indexing the selection history in bmesh

So for regular Python you can slice out all but the last two items of an ordered iterable type like a list or string with slicing and/or reverse indexing.

>>> letters = ['a','b','c','e','f']
>>> letters[:-2]
['a', 'b', 'c']

This does not work the same way with selection_history. For example, in edit mode with 5 faces selected, listing the items in the selection history I get this:

>>> import bmesh
>>> bm = bmesh.from_edit_mesh(bpy.context.edit_object.data)
>>> bm.select_history
<BMEditSelSeq object at 0x000002E8B0670450>

>>> len(bm.select_history)
5

>>> for i in bm.select_history: print(i)
... 
<BMFace(0x000002E8AFBC7768), index=33, totverts=4>
<BMFace(0x000002E8AFBC7730), index=32, totverts=4>
<BMFace(0x000002E8AFBC7420), index=18, totverts=4>
<BMFace(0x000002E8AFBC7298), index=11, totverts=4>
<BMFace(0x000002E8AFBC7260), index=10, totverts=4>

Nothing unusual so far. Now when you try to do slicing and/or reverse indexing with the selection history similar to the previous Python list example is where the problem arises:

>>> for i in bm.select_history[:-2]: print(i)
... 
<BMFace(0x000002E8AFBC7730), index=32, totverts=4>
<BMFace(0x000002E8AFBC7420), index=18, totverts=4>
<BMFace(0x000002E8AFBC7298), index=11, totverts=4>

Instead of printing just the first 3 elements in the selection_history (indexes 33, 32, and 18), the first and last faces in the selection_history (indexes 33 and 10) are being skipped. Is this a bug or am I misunderstanding something?

For now I am using kludgy code like this as a rough workaround:

endloop = len(bm.select_history) - 2
for i, elem in enumerate(bm.select_history):
    if i == endloop:
        break
    print(elem)

Submitted as bug here:

https://developer.blender.org/T54927

This is bug is fixed in the latest Blender master, but, for those still needing the workaround, I found this to be a bit cleaner then the last workaround I suggested:

endloop = bm.select_history[-2]
for elem in bm.select_history:
    if elem is endloop:
        break
    print(elem)