Reproducing randomForest Proximity Matrix from R package in Python
I have written some code for this. It can be found here. In answer to your specific questions:


I have tried to optimize for speed. What I did should be a little faster than the code above.
I do not use out of bag records. In fact the original documentation does not suggest this. I created another post to see if the consequences are understood.
This is handled in my code by normalizing by the total possible leaves that could be matched.