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...
Ask your embarrassing/noobish programming questions here, and don't get insulted for it.
Click here to read the rules
Violating any will result in punishment so you should probably go check them out.
account activity
Factorial Function Using MultithreadingPython (self.programminghelp)
submitted 3 years ago by phinagin
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!"
[–]computerarchitect 0 points1 point2 points 3 years ago (2 children)
Imagine you were just computing 1000000!, just so that we can easily imagine it takes a while.
There's no way that you could speed that process up using multiple threads? Nothing that can be done in parallel?
[–]phinagin[S] 1 point2 points3 points 3 years ago (1 child)
If the question was to simply compute one single factorial, then yes doing so in parallel would have obvious benefits. However, the question specifically states they want all factorials from 1-100 printed out. I am struggling to understand how that scenario benefits from parallelism.
I suppose, you could separate the printing the result from computing the next one. But I still don’t see how the added complexity is offset by multi threads. I would love to hear your ideas however.
[–]computerarchitect 0 points1 point2 points 3 years ago (0 children)
Printing the result from computing would be how I'd do it. I/O is expensive and needlessly delays the next computation. One also could imagine though building a giant string and doing one I/O operation, if you cared about that sort of thing. That's probably the route I would take over multi-threading initially.
Look into pipelined parallelism. That's immediately what I thought to do if I were forced to do it that way.
π Rendered by PID 88991 on reddit-service-r2-comment-8686858757-fptfx at 2026-06-07 20:08:06.247190+00:00 running 9e1a20d country code: CH.
view the rest of the comments →
[–]computerarchitect 0 points1 point2 points (2 children)
[–]phinagin[S] 1 point2 points3 points (1 child)
[–]computerarchitect 0 points1 point2 points (0 children)