Skip to main content
Code Review

Return to Answer

added 177 characters in body
Source Link
tsleyson
  • 1k
  • 5
  • 18

If you're interested in extending this class, there are a few tricks you could play around with that might help performance in some cases. One would be to keep your list of elements sorted, and use a binary search to check if the set contains a particular element. You could have add sort the list, and then have __contains__ call out to a binary search function. This will also make searching for duplicates faster. If you're dealing with custom objects, you can make them sortable like this .

If you're interested in extending this class, there are a few tricks you could play around with that might help performance in some cases. One would be to keep your list of elements sorted, and use a binary search to check if the set contains a particular element. You could have add sort the list, and then have __contains__ call out to a binary search function. This will also make searching for duplicates faster.

If you're interested in extending this class, there are a few tricks you could play around with that might help performance in some cases. One would be to keep your list of elements sorted, and use a binary search to check if the set contains a particular element. You could have add sort the list, and then have __contains__ call out to a binary search function. This will also make searching for duplicates faster. If you're dealing with custom objects, you can make them sortable like this .

linked formatter
Source Link

The community is sort of lukewarm on using an initial underscore to indicate a "private" member seecheck https://stackoverflow.com/questions/551038/private-implementation-class-in-pythonthis and and note how ambivalent everyone seems about the convention. After spending some time with Clojure, I never use any kind of "private" modifier in Python, but I'm sort of an extremist in that regard, and it can be useful if you're writing code that will be used by lots of other people.

The community is sort of lukewarm on using an initial underscore to indicate a "private" member see https://stackoverflow.com/questions/551038/private-implementation-class-in-python and note how ambivalent everyone seems about the convention. After spending some time with Clojure, I never use any kind of "private" modifier in Python, but I'm sort of an extremist in that regard, and it can be useful if you're writing code that will be used by lots of other people.

The community is sort of lukewarm on using an initial underscore to indicate a "private" member check this and note how ambivalent everyone seems about the convention. After spending some time with Clojure, I never use any kind of "private" modifier in Python, but I'm sort of an extremist in that regard, and it can be useful if you're writing code that will be used by lots of other people.

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

The community is sort of lukewarm on using an initial underscore to indicate a "private" member see http://stackoverflow.com/questions/551038/private-implementation-class-in-python https://stackoverflow.com/questions/551038/private-implementation-class-in-python and note how ambivalent everyone seems about the convention. After spending some time with Clojure, I never use any kind of "private" modifier in Python, but I'm sort of an extremist in that regard, and it can be useful if you're writing code that will be used by lots of other people.

The community is sort of lukewarm on using an initial underscore to indicate a "private" member see http://stackoverflow.com/questions/551038/private-implementation-class-in-python and note how ambivalent everyone seems about the convention. After spending some time with Clojure, I never use any kind of "private" modifier in Python, but I'm sort of an extremist in that regard, and it can be useful if you're writing code that will be used by lots of other people.

The community is sort of lukewarm on using an initial underscore to indicate a "private" member see https://stackoverflow.com/questions/551038/private-implementation-class-in-python and note how ambivalent everyone seems about the convention. After spending some time with Clojure, I never use any kind of "private" modifier in Python, but I'm sort of an extremist in that regard, and it can be useful if you're writing code that will be used by lots of other people.

Source Link
tsleyson
  • 1k
  • 5
  • 18
Loading
lang-py

AltStyle によって変換されたページ (->オリジナル) /