File tree Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Original file line number Diff line number Diff line change @@ -38,15 +38,9 @@ def __getitem__(self, key: Any) -> Any:
38
38
if key .start > key .stop and key .step > 0 or key .stop > key .start and key .step < 0 :
39
39
return []
40
40
41
- if key .start is not None and len (self )- 1 < key .start :
42
- self .primes += n_primes (key .start + 1 , self )[len (self ):]
43
- if key .stop is not None and len (self ) < key .stop :
44
- self .primes += n_primes (key .stop , self )[len (self ):]
45
- elif isinstance (key , int ):
46
- if len (self )- 1 < key :
47
- self .primes += n_primes (key + 1 , self )[len (self ):]
48
- else :
49
- raise TypeError ()
41
+ num_required = max ((key .start or - 1 )+ 1 , key .stop or 0 ) if isinstance (key , slice ) else key + 1
42
+ if len (self ) < num_required :
43
+ self .primes += n_primes (num_required , self )[len (self ):]
50
44
51
45
return self .primes [key ]
52
46
You can’t perform that action at this time.
0 commit comments