13,821 reputation
13358
bio website
location
age
visits member for 4 years, 4 months
seen 13 mins ago

Dec
17
comment Is true multithreading really necessary?
@WinstonEwert I am aware, but I tend to ignore it, because I consider that an optimization and because relying on it may mean breaking Windows supports. I consider that unacceptable, so I work with this model in mind, though it's actually faster on some platforms.
Dec
17
comment Is true multithreading really necessary?
That's not what I'm thinking of. Note that CPython does not share code objects, or anything else for that matter. It imports all modules again -- can you tell me why? (I have vague ideas but nothing cold and hard.) Please, at least have a throughout look at existing attempts (cough Python multiprocessing cough).
Dec
17
comment Is true multithreading really necessary?
That's not the issue. The issue goes deeper: this approach (not unlike locking) simply doesn't compose, i.e., two functions which are safe in their own right may not be safe when put together (for example, when f can and should wait according to its intended use, the combination wants to chain f and g atomically). Prohibiting yielding everywhere doesn't help, it just makes cooperation harder (and puts all the burden on the programmer gluing stuff together). Making APIs async is an "easy" way out but now you need great tools for working with them, to maintain the simplicity.
Dec
17
comment Is true multithreading really necessary?
You may want to look into why CPython does not do that (at least code objects are immutable). And there are probably many potential issues atop of that. I'm no expert, I've just seen a lot of weird multiprocessing errors.
Dec
17
comment Is true multithreading really necessary?
@JonathanGraef Note that one still needs synchronization when any function one calls in a critical section may wait. For example, global_x = foo(global_x) is atomic iff foo is atomic.
Dec
17
comment Is true multithreading really necessary?
You're assuming the ability to run arbitrary code in other processes. It certainly doesn't work that way with CPython, and honestly I doubt anyone can make it work with all code. Did you implement a prototype (or at least did similar things in the past) or are still planning?
Dec
17
comment Is true multithreading really necessary?
As someone noted in a comment on the question, the cooperative multitasking thing is independent of the GIL. CPython, for example, has preemptive multitasking but also a GIL. As for single-threaded code: I didn't say single-threaded code is "better". I said having no synchronization at all in the implementation (except a single lock that's only touched a few times per second) makes single-threaded code faster because lots of unnecessary (for single threaded code) locks go away. The alternative is compiling a separate interpreter without locks and threads, but that creates other headaches.
Dec
17
comment Is true multithreading really necessary?
Concurrency != parallelism. And as the question explains, threads aren't the only option for parallelism.
Dec
17
comment Is true multithreading really necessary?
RE reasons: Possible reasons include simplicity of implementation, somewhat better performance of single-threaded code, some weak atomicity guarantees (the last one is actually a downside depending on your POV, but some like it).
Dec
17
answered Is true multithreading really necessary?
Dec
17
comment Is true multithreading really necessary?
The first use case is concurrency (which he does offer), not parallelism. Python programmers do that too, despite the GIL.
Dec
17
awarded  Nice Answer
Dec
16
comment Could a programming language work as well without statements?
@sparkleshy The "ugly thing" in paragraph 1 would be the removal of syntax for statements (e.g. statement separators) following the realization that one "doesn't need" statements.
Dec
16
comment Could a programming language work as well without statements?
@sparkleshy (1) You may be confusing expressions (which can the sole component of a statement) with statement (which aren't expression and have no result value). (2) What? Any FP advocate will confirm that (and argue that it's a good thing). Or is it only the "all" part which you object to? (3) {} blocks are what I'm talking about ("notion of sequential instructions"). And where do I say anything causes any problems? The difference between void and null/unit is that the latter are values and can be passed around, whereas void is special in that there's no value of that type.
Dec
16
comment Could a programming language work as well without statements?
@sparkleshy What part isn't true, and how?
Dec
16
answered Could a programming language work as well without statements?
Dec
12
comment Is it ok to ignore poor performance for a resource that will be cached?
Caching is not a magic bullet in general. Is it in your case?
Dec
11
comment How, when, and why do developers use custom data structures in python?
A more common (due to its generality) data structure not in the Python standard library is a graph. This is partially because (as python-ideas recently discussed) there are so many radically different uses of them that a single implementation can't possibly cover most use cases. I regularly create graphs, though they're rarely explicitly treated as such.
Dec
11
comment Is there a modified LGPL license that allows static linking?
What would distinguish that license from non-copyleft licenses?
Dec
11
answered C# Algorithms for * Operator