Skip to main content
Code Review

Return to Answer

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

titles = [jobs[i]['title'] for i, v in enumerate(jobs)] can (should?) be rewritten :

titles = [j['title'] for j in jobs.items()] because we just want to access the value at position i (More details More details)

Thus, the whole code would be :

def splitData(jobs):
 salaries = [j['salaryNormalized'] for j in jobs.items)]
 descriptions = [j['description'] + j['normalizedLocation'] + j['category'] for j in jobs.items)]
 titles = [j['title'] for j in jobs.items)]
 return salaries, descriptions, titles

Not quite sure how much it helps from a performance point of view.

Edit : Otherwise, another option might be to write a generator which returns j['salaryNormalized'], j['description'] + j['normalizedLocation'] + j['category'], j['title'] as you need it. It depends how you use your function really.

titles = [jobs[i]['title'] for i, v in enumerate(jobs)] can (should?) be rewritten :

titles = [j['title'] for j in jobs.items()] because we just want to access the value at position i (More details)

Thus, the whole code would be :

def splitData(jobs):
 salaries = [j['salaryNormalized'] for j in jobs.items)]
 descriptions = [j['description'] + j['normalizedLocation'] + j['category'] for j in jobs.items)]
 titles = [j['title'] for j in jobs.items)]
 return salaries, descriptions, titles

Not quite sure how much it helps from a performance point of view.

Edit : Otherwise, another option might be to write a generator which returns j['salaryNormalized'], j['description'] + j['normalizedLocation'] + j['category'], j['title'] as you need it. It depends how you use your function really.

titles = [jobs[i]['title'] for i, v in enumerate(jobs)] can (should?) be rewritten :

titles = [j['title'] for j in jobs.items()] because we just want to access the value at position i (More details)

Thus, the whole code would be :

def splitData(jobs):
 salaries = [j['salaryNormalized'] for j in jobs.items)]
 descriptions = [j['description'] + j['normalizedLocation'] + j['category'] for j in jobs.items)]
 titles = [j['title'] for j in jobs.items)]
 return salaries, descriptions, titles

Not quite sure how much it helps from a performance point of view.

Edit : Otherwise, another option might be to write a generator which returns j['salaryNormalized'], j['description'] + j['normalizedLocation'] + j['category'], j['title'] as you need it. It depends how you use your function really.

Source Link
SylvainD
  • 29.7k
  • 1
  • 49
  • 93

titles = [jobs[i]['title'] for i, v in enumerate(jobs)] can (should?) be rewritten :

titles = [j['title'] for j in jobs.items()] because we just want to access the value at position i (More details)

Thus, the whole code would be :

def splitData(jobs):
 salaries = [j['salaryNormalized'] for j in jobs.items)]
 descriptions = [j['description'] + j['normalizedLocation'] + j['category'] for j in jobs.items)]
 titles = [j['title'] for j in jobs.items)]
 return salaries, descriptions, titles

Not quite sure how much it helps from a performance point of view.

Edit : Otherwise, another option might be to write a generator which returns j['salaryNormalized'], j['description'] + j['normalizedLocation'] + j['category'], j['title'] as you need it. It depends how you use your function really.

lang-py

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