Skip to main content

Timeline for Password checker in Python

Current License: CC BY-SA 3.0

14 events
when toggle format what by license comment
Jun 8, 2017 at 9:03 comment added Graipher Yeah, the size of the needle is also in there (which didn't matter here, because it was always a single character): stackoverflow.com/a/18139681/4042267
Jun 8, 2017 at 9:01 comment added Peilonrayz @Graipher I definitely will, :) I don't know why I thought c in str was \$O(1)\$ when I knew str in str is \$O(n)\$, or is it \$O(nk)\$... I'll definitely keep it in mind, :)
Jun 8, 2017 at 8:58 comment added Graipher Yeah, since len(letters) is probably bounded by the ASCII table size in the worst case. Still, its a thing to keep in mind that c in str is not \$\mathcal{O}(1)\$.
Jun 8, 2017 at 8:56 comment added Peilonrayz @Graipher Whilst I mistakenly thought char in string is \$O(1)\$. The worst case difference here, on my machine, is ~3.2e-08.
Jun 8, 2017 at 8:35 comment added Graipher Because any(char in letters for char in input) is \$\mathcal{O}(nm)\$ with n = len(input) and m = len(letters) in the worst case (none of the characters are in letters). By defining the constant as a set you pay that \$\mathcal{O}(m)\$ once and check_contains becomes \$\mathcal{O}(n)\$.
Jun 8, 2017 at 8:01 comment added Peilonrayz @Graipher Why as sets? IIRC strings are as good. But yeah, punctuation may be better as a constant, :)
Jun 8, 2017 at 6:20 comment added Graipher If many passwords need to be validated, you probably want to define global constants for the character classes as sets.
Jun 7, 2017 at 19:04 comment added Peilonrayz @grundic thanks, I legitimately forgot to add them, );
Jun 7, 2017 at 19:03 history edited Peilonrayz CC BY-SA 3.0
Oops add the imports...
Jun 7, 2017 at 19:02 comment added grundic Sure ;) And don't forget to import string :p
Jun 7, 2017 at 18:53 comment added Peilonrayz @grundic I edited to add that, I don't like having to remember it's 'lowercase', rather than 'lower' so I normally skip using it, ;P
Jun 7, 2017 at 18:52 history edited Peilonrayz CC BY-SA 3.0
Use string
Jun 7, 2017 at 18:49 comment added grundic You can replace hardcoded letters with string.ascii_lowercase, string.ascii_uppercase and numbers with string.digits as stated in the documentation
Jun 7, 2017 at 18:44 history answered Peilonrayz CC BY-SA 3.0