I think it makes perfect sense to ignore this.
Edit: actually it's higher than `O(number_of_heap_objects)` for refcount, because you can trigger a cycle collector which is unlikely to be `O(N)`
In my first post, I was mostly focused specifically on CPython, which does ref-counting with some GC to catch cycles. I was ignoring the real GC and cycles in my post; my understanding of d.clear() is that the ref counting happens and happens immediately, so at best it's still O(|d|). My main point was that in the implementation you're likely to be using, it happens at the time you run the code, and can thus change the order notation of the code (and perhaps how you expect it to perform, though you did have to construct d, which was O(|d|) at best to begin with…).
In a generic GC, I was thinking it might be fair game to ignore the GC. If GC can be done completely concurrently with the remainder of the app, and doesn't end up effectively stealing resources (mostly, CPU, I guess) from the app, then I think I might be persuaded to call it "free", or at least close to it. One might cynically call a "never free; just alloc and let the OS free on process death" a very naive form of garbage collection, and there, it is definitely close to free.
Also, I think some of these are great examples of just how easy CPython's implementation is to read in many cases.
[1]: see this, for example: https://github.com/python/cpython/blob/0eb5f5996feed30ade8c2...
[2]: https://github.com/python/cpython/blob/0eb5f5996feed30ade8c2...
[3]: https://github.com/python/cpython/blob/0eb5f5996feed30ade8c2...