Previously, os.path.isdir was one of the biggest time sinks in spinal.
Switching from my custom code to os.walk, thanks to its use of scandir,
saves a lot of time. For searching my 2TB drive with a hot cache, time
shrank from 70s to 35s.
However, os.walk doesn't support breadth first search, so that's gone
unless I reimplement os.walk myself to support it.
I often found myself writing code like if a.extension == 'png' and
trying to remember if I'm supposed to compare against 'png' or '.png',
and then it would trip up on files like A.PNG because I forgot to
lower() it.
So this class handles all that for you. You can == against it and it
will use os.path.normcase to give you OS-appropriate case sens,
and == works whether you include the dot or not. Then you can use
ext.with_dot or ext.no_dot to get reliably dotted strings.
I am considering some other instance attributes similar to force_sep.
And since these need to be carried over into newly spawned Paths,
I want to consolidate that into a single method so I don't have
to risk forgetting it on a new object.
The literal function will still be a bit more strict on the types
it accepts, but if you have something that you know is okay
to iterate you can call listify directly.