« first day (4310 days earlier)      last day (636 days later) » 

1:10 AM
Submitted without comment: stackoverflow.com/questions/57049191
 
 
1 hour later…
2:30 AM
@metatoaster This might actually be a very good start for a canonical answer to the direct question of what is __new__. All other questions are a little indirect. — Bharel 9 mins ago
should I reopen that based on that comment?
 
 
6 hours later…
8:20 AM
Hello
Hello folks, i have a question, is there a chat room for Spark devs?
 
@f.ivy hi, I doubt it. A filterable list of chatrooms is at chat.stackoverflow.com/rooms?tab=all&sort=active, and the same for chat.stackexchange.com
 
@andras
thanks
 
8:46 AM
if I have two coroutines async_foo(my_list) and async_bar(my_list), and both read and write to my_list, do I need asyncio.Lock here?
I kinda understand how threading.Lock works with normal functions, but do not understand why I would need asyncio.Lock
 
The question is whether the coroutines can be executing concurrently with one another
 
yes they are running concurrently
 
And whether your code breaks in that case
 
that is where I am stuck, I can not find out if I need a lock or not, I have to hit a race condition somehow?
if at all there is a race condition
 
You have to think about what your code does, where execution can be suspended, and whether that can cause issues while your code is running
 
8:51 AM
googling "are python lists asyncio safe" is not that helpful
 
When in doubt you should default to "yes, there is a race condition".
 
The question is whether the two coroutines do any operations on the list that are not (pairwise) concurrency-safe.
For example, removing items from the list and concurrently iterating the list is not safe.
 
@MisterMiyagi wdym by "pairwise" here?
 
That the pair of operations A, B (e.g. remove, iter) is not concurrency safe, even if each individual operation would be.
 
@MisterMiyagi so if I were to do exactly this, I would need a lock at both my_list.remove() and a lock at for i in my_list?
 
8:57 AM
yes
 
I just can not seem to find a source (for async) that tells me list.foo is atomic, list.bar is not atomic
for now I will go with Andras' suggestion of assuming its a race condition everywhere
hope the performance hit won't be a lot
 
It's not so much atomicity. Your code won't necessarily crash. But certain operations just don't have useful behaviour in concurrent situations.
E.g. the remove+iter pair is bogus even in synchronous code when run concurrently.
 
yeah I fall victim to this every once in a while
 
What exactly do you use the list for anyway? Why do both coroutines read/write to the same list?
 
I have 5 coroutines fetching data from 5 different sources, I just collect all these data and put them into my list, that is the read part, the write part is, there is a 6th coroutine that sorts it and dumps to a JSON
 
9:06 AM
You most likely want a Queue, then.
 
so I push to the queue with my 5 coroutines, and the 6th one consumes from the queue to a temporary list and I sort that?
 
9:31 AM
You're sorting and dumping it while other tasks are still collecting data? O.o
Weird thing to do, but it's async safe. Don't need a lock for that
sort, json.dump and list.append are all "atomic" operations as far as asyncio is concerned, because there's no await
 
doesn't sort do inplace sort?
 
Yes?
 
I would normally expect that to mess up things in thread concurrency, so I applied the same here, guess its not huh
 
The problem with threads is that they actually run at the same time. Thread 1 could try to modify the list while thread 2 is sorting it. That can't happen with asyncio
Unless you write your own sorting algorithm and put an await in the middle of it
That's the neat thing about asyncio, you know exactly that other tasks can only run when you let them (by using await)
 
9:47 AM
so whats the simplest case where I need asyncio.Lock?
 
I actually can't come up with an easy example
I guess it's probably easier to explain than write code for it
 
async for broken_iter(items: list):
    for item in items:
        print(item)
        await asyncio.sleep(0.1)  # <<< other operations can run concurrently
If you have something like this then you would need locking if anyone else modifies the list.
 
I changed my mind, it's not easy to explain either
 
I kinda get what is happening now, thanks guys
 
 
2 hours later…
11:54 AM
Python
 
Yes. But perhaps I will say more things later anyway.
 
12:08 PM
en.wikipedia.org/wiki/SKI_combinator_calculus describes a Turing complete programming language that has variables and single-argument function calls and nothing else. But perhaps "variable" isn't an accurate term, since assignment is impossible. If you don't like the initial values of S, K, and I, then too bad for you.
 
> it is an extremely simple Turing complete language. It can be likened to a reduced version of the untyped lambda calculus. It was introduced by Moses Schönfinkel and Haskell Curry.
that's also nuff said for me
 
@Kevin variable just means it is a placeholder that can take values. It doesn't have to be able to take multiple values one after another.
 
You don't have to vary to be a variable, but it helps
It could be a fun project to write a parser for SKI. If you decide that [expr1 expr2] is the syntax for function calls instead of expr1(expr2), then a recursive descent parser would be pretty straightforward to write.
Despite its simplicity, I don't see many "top 101 cool project ideas for beginners" lists that propose it. Maybe it lacks visual impact. You can't easily get it to print "Hello, World!".
 
recursive descent into madness, I imagine
 
 
3 hours later…
3:03 PM
Is there a generic canonical for "parse literal contained in a string" (i.e. "use ast.literal_eval")? I've found one specifically for strings but it has some baggage of an earlier unclear state of the question.
 
 
1 hour later…
4:21 PM
I did it. I finally did it. I defeated Jenkins, that horrific code that looked like bash, and the file encryption. I can finally fix 4 years worth of horrible data ingest pain. <completely deflates from the sigh of relief>
 
Breathe, josh, breathe!
Deflating sounds unhealthy
 
Now to build my own completely impenetrable ingest machinery and cement myself as indispensable, slowly drip feeding data on a whim. It was my devilishly evil plan all along, you see!
 
@roganjosh 🥳
 
5:00 PM
Taking some corporate training on malware. One section is titled "How to identify malware in Python". Its advice boils down to "if the malware's filename ends with .py, it may be Python"
 
Did you know? Python is almost as powerful as Powershell, although Python lacks essential control elements such as case and do.
 
@Kevin Neat
 
5:39 PM
Coworker: "we're still trying to get the tech stack for the new project working. CoolJavascriptThing2021 depends on neatDotNetTool2020, which depends on Python 2.7"

Me: [Preparing to die on this hill] "I --"

Coworker: "Hold that thought Kevin, we'll circle back to that."

Still waiting to circle back.
 
6:10 PM
Anyone here fluent in django I have a question about it
 
I don't like to make a big deal about it, but, heh,
I have over two hours of experience with Django
 
 
3 hours later…
9:05 PM
cbg
 
@MalikBrahimi yeah, no. Try the unix & linux chatroom on chat.stackexchange.com
 
ok sure
 
@Kevin python is a systems language, it's not used for data processing. Asking to learn python is like asking your employer to sponsor you to learn German
^ how biting my lip during that exchange didn't end up with me eating my own face, I don't know. My subterfuge was too strong
Joke's on them. The guy I was trying to get access to python at the time now works for us, and he delivered his resignation while they were literally smashing down a wall to make a new sub-office space for him in IT. Alas, he didn't tell them "I'm off to learn German". Missed opportunity.
 
9:22 PM
I'd think the joke's on whomever pays for that reconstruction :P
 
Eh, they'll fill the desk somehow. Another advocate for the AS400 that does everything, like poop unicorns as an example
 
stackoverflow.com/questions/58254234 I answered this in 2019; but is it a duplicate? It seems like there are a lot of potentially "related" questions, but I like having this kind of overview.
oh, the next result in my internet search (though I am already a couple pages down) seems like the duplicate I want for that. stackoverflow.com/questions/35121288
 

« first day (4310 days earlier)      last day (636 days later) »