Last active
September 12, 2016 18:35
-
-
Save jtallieu/4c08bcf0963b9f8cd53e0dd710872dde to your computer and use it in GitHub Desktop.
Eagle Eye Networks Inc :: Python screening sample - String handling optimization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
::Eagle Eye Networks Inc.::: | |
::Python screening:: | |
The following script is purposley written poorly. | |
Improve upon the code and explain your improvements. | |
The id_csv method must return a unicode string of | |
representation of a comma separated list of uuid's | |
""" | |
import uuid | |
import string | |
import cProfile | |
def id_csv(limit): | |
"""Generates a comma separated list of uuid's""" | |
id_list = u"" | |
while limit: | |
limit -= 1 | |
id_list += str(uuid.uuid4()) | |
if limit: | |
id_list += ", " | |
return id_list | |
if __name__ == "__main__": | |
print id_csv(10) | |
cProfile.run("id_csv(10000)") |
👍
👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output from above code.
Re-written output: