On some SxS offices which a 4 digit number, the third digit would be the party code. So I could be 5718 and my neighbor 5728, the 1 and 2 indicating the party code.
This was one of the challenges they faced in implenting DDD. Obviously some offices took longer than others to convert. Well into the 1970s the telephone directories for small towns had complex directions of dial codes depending on where you were and where you were calling. Sometimes you had to wait for a second dial tone or special tone. Adding tandem switching (switches that connect between central office) was a challenge too.
I would presume (and have heard) that party line users were located close to each, since the whole idea was to share the same physical line to the C.O. How it was handled in cities, where in the old days many people had party service, I don't know.
Indeed, one of the postwar challenges of the Bell System was the demand for private line service instead of party service as people got more money and could afford it. Originally party service had a big discount but as time went on it wasn't as significant. The paperwork to track cabling and lines must have been enormous.
However, in some 1950s Bell System publications, they said one of the limiting factors in giving more private lines (demand exceed supply) was that central offices didn't have the capacity. Party service was a way to keep down calling volume until they could expand. In many cases that meant a new building which of course was expensive and time consuming. (I know of city Bell Telephone buildings where it is obviously some upper stories were added.)
I do wonder if any outside auditors checked to see if the Bell System was indeed adding capacity as demand required in the 1950s. Could Bell have bought gear from Automatic Electric? Hired more installers? I will note that in the 1950s the military was expanding and Bell had military contracts for both basic phone systems and advanced radar and other systems. Other companies at the time did so as well, and this was respected by the public. Companies in that era ran ads (similar to that of WW II) "Defense needs come first -- please be patient". (It wasn't until the later 1960s that some would question Bell System defense projects.)