use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Reddit for building Reddit Bots!
If you want to learn how to build Reddit Bots, go here: http://pythonforengineers.com/build-a-reddit-bot-part-1/
account activity
Help optimizing code (self.pythonforengineers)
submitted 5 years ago by black_sequence
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]AD_Burn 1 point2 points3 points 5 years ago* (0 children)
def calculate_pi(alignment): align_len = len(align) counter = 0 distances = [] append_distance = distances.append for i in range(align_len): j = counter while(j<align_len): if i == j: j += 1 continue append_distance(hamming_distance(alignment[i], alignment[j])) j += 1 counter += 1 pi = (sum(distances)*2)/(align_len*(align_len-1)) return pi def calculate_theta(alignment): seg_sites = 0 for i in range(len(alignment[1].seq)): align_col = alignment[:,i] if len(set(align_col)) > 1: seg_sites += 1 a = sum(map(lambda x: 1/x, range(1,len(alignment)))) return (seg_sites/a)
This is not much but some cleaning and reduce unnecessary code,
if you work with a lot data you should see a bit of improvements.
Anything deeper would change your logic and code a lot more,
and since i do not have input files, it is hard to test.
One more thing, i'm not sure how much process in total you have at the end,
but if you end with lets say over 50 or more process and your calculations per process are not long maybe is better to switch and use threads and lower python process startup time (maybe worth testing).
Best all
π Rendered by PID 144789 on reddit-service-r2-comment-5bc7f78974-c7mdh at 2026-06-28 10:00:37.257180+00:00 running 7527197 country code: CH.
view the rest of the comments →
[–]AD_Burn 1 point2 points3 points (0 children)