Skip to content

Commit 2395098

Browse files
kill uniqify for sorted(set(...))
1 parent 5e91ae2 commit 2395098

File tree

4 files changed

+4
-14
lines changed

4 files changed

+4
-14
lines changed

pyrepl/cmdrepl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def __init__(self, completions):
5353
def get_completions(self, stem):
5454
if len(stem) != self.pos:
5555
return []
56-
return cr.uniqify([s for s in self.completions
57-
if s.startswith(stem)])
56+
return sorted(set(s for s in self.completions
57+
if s.startswith(stem)))
5858

5959
def replize(klass, history_across_invocations=1):
6060

pyrepl/completing_reader.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@
2121
from pyrepl import commands, reader
2222
from pyrepl.reader import Reader
2323

24-
def uniqify(l):
25-
d = {}
26-
for i in l:
27-
d[i] = 1
28-
r = d.keys()
29-
r.sort()
30-
return r
3124

3225
def prefix(wordlist, j = 0):
3326
d = {}

pyrepl/module_lister.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
1818
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1919

20-
from pyrepl.completing_reader import uniqify
2120
import os, sys
2221

2322
# for the completion support.
@@ -38,9 +37,7 @@ def _make_module_list_dir(dir, suffs, prefix=''):
3837
l.append( prefix + fname )
3938
_packages[prefix + fname] = _make_module_list_dir(
4039
file, suffs, prefix + fname + '.' )
41-
l = uniqify(l)
42-
l.sort()
43-
return l
40+
return sorted(set(l))
4441

4542
def _make_module_list():
4643
import imp

pyrepl/python_reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def get_completions(self, stem):
155155
return [x[len(mod) + 1:]
156156
for x in l if x.startswith(mod + '.' + name)]
157157
try:
158-
l = completing_reader.uniqify(self.completer.complete(stem))
158+
l = sorted(set(self.completer.complete(stem)))
159159
return l
160160
except (NameError, AttributeError):
161161
return []

0 commit comments

Comments
 (0)