#python-discussion
1 messages · Page 212 of 1
"Cybersecurity software maker CrowdStrike said in May that it’s laying off 5% of its workforce or 500 employees, and directly attributed the cuts to AI."
And again, these are companies that have a vested interest in the idea that AI is good enough to replace human workforce, whether that's true or not.
Your right about that. But that's not the only thing.
Alright you got me there, I can't deny it then :)
i think theory lemme pull up my notes
It's still not clear exactly how AI has allowed them to reduce their workforce.
why did they lay off 5% of their workers and not 100%?
@dry yacht https://docs.google.com/document/d/1IyRlerYYLpIXZeMefvfLZHm_AP_S9nVSMw7fZpMcJLI/edit?tab=t.x3o3sfc9a20s#heading=h.nbiwng50na4d
the data structures tab
Lots of companies prematurely fired a lot of people and tried to replace them with AI, and then had to rehire them later when it turned out the AI was too unreliable.
ceo ain't gonna clean their own desk
Well AI isn't good at some aspects. So Entry-Level Programmers get fired and I would say that now there's more competition and higher requirments
In my experience AI is not even remotely good enough to replace entry level programmers.
Well I have no clue now, I see diversed opinions about it.
do you think it will be? like is there any point in me going to go do like a cs degree if it's gonna be obselete by the time i finish it? (like 8 ish years time)
I don't think LLMs will ever be.
Maybe there will be some other technological revolution in the future, and I can't speak about that.
8 years is a long time
That's always been true... Just look at doctors from 1926 VS 2026
We even have to go to universities! Medicine is done, now that the patient can just buy pills at the pharmacy...
A good school will have adapted their program by then if needed
3 more years in the irish education system plus 4 years in a degree
But the current transformer architecture I think has fundamental limitations that will ensure it's never more than a tool.
Same, I still have time to change career paths.
But at the endd of the day, you can still not do Computer Science if you think that's true. Like if yo u truly believe AI is going to replace coding, then don't do it!
You got a great point there.
yeah and i've heard that the job shortages are temporary but i could be wrong
Most likely job demand will ebb and flow over time.
how would it work if AI took over programmers jobs? like how would they continually run and update files wouldnt they still need human operation?
i want to do it cos i like coding and computers in general
and i have like 20 copy pages filled with me trying to make logic gates in binary
There still will be programmers working on it for example AI Engineers will be high in demand.
I mean, if we had AGI they'd be completely autonomous.
It'd be as if it was a person.
I think going for a CS education is a completely rational choice.
AGI is pure marketing, it's not worth talking about
If AGI is implemented, humanity may not survive.
that's a silly statement
There is no indication that anybody anywhere in the world has even the slightest clue what's needed to build an AGI.
Elon Musk least of all.
what was that optimus thing he was talking abt some time ago?
That guy talks a lot. It's not really worth taking seriously.
If you need code which is not maintainable,scalable , doesn't respect the project structure and just works code LLMs are fine but the code debt they create will be overall loss to the company.
Then how are the other companies doing it then.
that's a short term thing. You have to have entry level positions to have more senior positions, medium term getting rid of entry level will result in lowering requirements
It doesn't really work for anything beyond the absolutely trivial.
I encourage you to really look into stories about replacing developers with AI
Yeah, that's also a good point. Even if it was possible to replace juniors, which it isn't, it'd create a shortage of workforce in the long run.
frankly, it's not happening
isn't that what's happening now
No, it's not.
tech was on a decade long hiring glut, and is correcting
i thought a whole bunch of companies have stopped hiring juniors
bug bounties on open source projects are probably among the strongest damnations against llms right now. cURL is killing theirs because they're getting absolutely swarmed with hallucinated reports of CVEs that don't actually exist with code fixes that don't actually compile
without LLMs, not much would have changed re layoffs
That's not because of AI.
why is that now
so then consequently, in a few years time there should be a boom?
Because it was a technology boom then a tech shortage then another boom now due to AI Misinformation there's gonna be another shortage then another boom due to this shortage...
That's because of post-COVID layoffs and rising interest rates reducing positions and releasing a bunch of more experienced developers into the job market.
also, legitimately, while there may be good individuals in leadership and management, at any scale leadership and management are largely shit
i think theory lemme pull up my notes
Nah, this is "just" how to use it.
Theory would be like, for example forlistthat it's array-based and that operations likeappend(),pop(), oroperator[]are guaranteed to run in (amortized)O(1)because of how it "exponentially" resizes itself.
These docs just show how you can use it in Python.
not necessarily, tech as a whole has been over invested in for a while
oh well
There may be. If the economy recovers and fewer people study CS, there may be way higher demand down the line.
why is just in speech marks
Because that can be quite a lot in the beginning anyway
good enough for me then
admittedly, this raises the question of the actual threat: it's not whether LLMs can replace programmers, it's whether LLM hawks can convince ignorant boards and HR that they can replace programmers. the former is probably impossible. the latter, not so much
i heard a thing that ai is meant to be getting worse due to more ai slop could be wrong tho
That'll self-correct over time though.
granted, but it'll hurt pretty bad for a while
I mean they should make something like a dislike system on GitHub, so If someone with a project with 32 stars disliked you, it'll be -32 or something so people don't submit obvious AI code.
@golden mortar what do you work as
Software engineer
in fintech
and just out of curiousity did u do a cs degree
Yes, I have an M. Sc in CS
how many years is that now
I graduated in 2014
In Belgium?
Nope
5 years
plus the undergrad is 9
9 years jeez
financial technology
Huh?
Oooh
do you mean like pre-university high school or something?
funtech sounds fun, though
damn i just got accepted for an interview for my post 16
oh wiat maybe ur college system works diffrently is the m.sc a stand alone degree or did u have do smth before it
in ireland you have to do an undergrad in smth and then u "add" to that
I think in some countries you have to do like a 3 year bachelor and then a 2 year master, but at my uni it was a single 5 year program
I got my graduatio 12 years late 😅 in 2025 ☺️
When I did my BSc in CS it was a 3 year degree. Honours was an additional year. A masters was probably 5 all up then - BSc plus further work.
Indeed
Can you still get hired without a degree even if you know everything?
years so it's a masters in ireland which is 1 years plus the undergrad is 5 so yeah
In Sweden they changed it a while ago so thatnow you usually (always?) get a bachelor on your way to the M.Sc.
Yes.
Ok, it wasn't like that in my time
Easy Peezy
My time was 5 years as well
I dont need 5 years
No bachelor
Having a degree helps at the outset though - it effectively says "this person's spent time and learnt an expected spread of knwoeledge".
It's not easy to break through the crowd, but it is possible.
Ill build an impressive portfolio and ill just take the exam of CS
How will the company assess that you know everything?
Interview
Are they gonna interview you for 5 years? I think many companies will be looking at grades.
Some industries or companies that do government contract may require a degree. Other companies don't care (but without a degree, you'll need other experience, usually)
I've seen people do it without
but to get experience I need to get hired
right
There's no "exam of CS". A degree requires attending and passing courses so that the university knows you've covered what they consider necessary. You can get extra credit for some things to avoid some courses, but that's usually when you switch degrees or come from another university where you've already done equivalent stuff.
I'm always curious about that. In the dozens of jobs I've had, I've never had my grades looked at. (to my knowledge)
If there is one person with a degree, and one without, I would probably pick the one with.
There's stuff you learn in a degree you don't learn independently in the world unless you're interested in the theroy etc, and the theory does inform the way you think and gives you better tools for thinking.
Oh, I gave my grades to them if I remember correctly. But I was 0 and 1 year out from uni resp.
Nope, You have to be enrolled but you don't have to attend courses. Professors don't check who came and who didn't you show up on the exam and make it and that's it
It it true that attendance at lectures isn't checked. But attendance at tuorials sometimes is. You could show up at just the exam (and the practical assignments during the course). I don't like your odds.
In Sweden comp Sci you would have 4-5 exams per semester, some mandatory tasks/laborationsand and some project courses.
hey guys
Of course you can skip the lectures. But to me they were a great (the best) way to learn. At least for mathematics.
sure, you don't technically have to attend courses, but it's very unlikely that you'll pass courses in later years without attending them
passing tests without learning the material only works for basics you already know, and falls apart once you need to learn new stuff
or just do what i do
learn the material at home and skip the lectures
I'm already focused on learning coding; why should I enroll if I already know the material?
Idk about Sweden, but i know that except for some degrees like medical, such thing was done to make degrees more compatible between EU countries.
And also I'm saying if you know the material, if you don't then ofc you have to attend
CS doesn't teach you how to code. The stuff it teaches is tangential to learning to code, and teaching yourself to code won't teach you the stuff you learn in a CS degree.
If that works for you, all to the good. FOr. lot of people it's helpful to be there; I at least learnt better by being there and writing notes as things went. Just watching/listening is less effective.
Well Ill just learn what they learn right now
when i do go i try to participate
though one of my professors banned me from answering questions because i always give the answers too quickly .-.
cuz I want to have multiple degrees without doing 10 years of attending classes
Good. If that works, fine.
i dont like the public setting of universities too much
Instant answers does reduce the engagement of the other students.
sure, obviously you can self-study all of the material required for a degree. Most people struggle to do it, though. Most people really have trouble forcing themselves to learn material that they don't find interesting without the pressure of grades and deadlines
Medical has been made more similar in EU as well (in Sweden we switched "AT "-> "BT" to become more similar)
And answers always from one student also reduces their engagement.
i get it, but then again i dont see the point of going if i ruin it for others just by participating yknow?
Then don't go.
just answer second.
That's reasonable, it's better to answer if you are UNSURE then if you are SURE. 🙂
I meant like medical doctor is 5y and MSc or equivalent level, not BSc level (at uni, there's only PhD after that).
I'd usually wait a little and answer only if it seemed like no one else would
or they can wait until their teacher calls them or sometimes not answer
Which was most of the time
it's called being fair
what i can recommend for people in my position is that it might be better to ask questions rather than giving answers
good questions make professors happier than good answers for some reason
Means you're thinking, and that they don't have to prise answers out of a class.
I'm not exactly sure what you mean. Medical Doctor here was 5.5 + 1.5 = 7 years, but they changed it to 6 years
personally I don't see the benefit of the lecturer asking closed questions during lectures. much better for students to ask questions themselves instead
i think it also gives them an opportunity to naturally bring up subtleties that they would want to put as an aside
For uni itself, it's 5y here and has no BSc level. That's just uni - not counting years of residency in hospital and specialisation after that.
I was adding to "now 5y programmes were split and there's BSc" thing that there are exceptions to the split even in EU
6 or 7 years
😛
and the odds are very low that you'll find all of the material for the degree interesting. I would have never been able to self-teach systems architecture or linear algebra, for instance. I find them both incredibly boring.
yea I was a bit wrong, previously it was 5.5+1.5+5 years, now its 6+0.5+5
Non-engineering degrees here are 3y for BSc + then 2y for MSc
Engineering is 3.5 + 1.5
Unified programme (no BSc in between) for e.g. medicine is 5y
I see, yes I was just considering technical science (engineering/math/computer/physics) when I made that remark.
Where are you?
Poland
Cool, I did python programming for Ericpol at Ericsson, so visitted Krakow twice 😄 Cześć @harsh swallow
would people in 200 years be impressed with coders not using ai like we're impressed with mathematicians 200 years ago not using calculators
I mean I'm not impressed by mathematicians not using calculator
Like Obviously we didn't use calculators whole learning mathematics
and using LLMs while learning to code is like using a forklift while lifting weights at the gym
Well, OP didn't specify learning
you can't be a coder without learning to code, right?
Right
Proper maths people use equations and calcs are typically using numerical approximations which is different
Even if "AGI" does replace you, that just makes you a prompt-inator, not a developer yourself
I've been personally arguing with a prompt engineer about the quality of his code (since it's generating ginormous files etc) and lots of smells and he is convinced the toolchain doesn't need a good dev any more!
"proper math" is just not very well defined
I don't disagree with you here; it's a vague idea
You can 'dress up' proper formulated mathematics in code and tensor arithmetic but it might still not be peer reviewed actual quality content and might even be pseudoscience written by a carried away philosopher
Back then they only knew like the first twenty primes and couldn’t count higher than like, 37. (Exaggerated for effect)
huh?
I'm referring to some messy code and ideas that a non dev friend has shared with me but doesn't want sharing publicly in a sarcy manner
AI code reminds me of perl. It’s best for a single one time use then discarded.
I saw that 'pearl' of wisdom!
funny, one of the few times I use AI it is to make single-use perl code.
like to edit a bunch of config files or some other one time refactor.
People discarding AI like this, have you tried agents like Claude Code? (I haven't but I might soon)
Theo has a recent vid reacting to an article about how code is now cheap, but software is still expensive.
I have a claude code subscription at work and a trying to give it an honest go.
I've heard that Claude Opus is not bad (I've tried Claude others; they make a mess of your code) - OpenAI seems almost OK
I tried google gemini as well; did not get on with it
I have access to various AI agents through my IntelliJ Idea subscription
WE only have weaker non-claude models at work, so Ive tried claude vs those, but it's obvious that it's not working as well as it should be.
Some friends of mine had some fun with local AI generating little 10s vids. They used a 5090
I'm a poor man with only a 4060 🙁
I didn’t understand what any of that meant except video is somehow involved 😆
Good conversation but can we AI in #ot0-psvm’s-eternal-disapproval
old joke
Old joke, doesn't work, and we don't like even "joke" malicious code here
I have a laptop without dedicated GFX :3
Please don't use potentially destructive things as examples, even as a joke.
Ok sorry
It always annoys me that those "jokes" use os.remove which literally can't remove directories, ever. At least be creative and verify your joke, making this mistake shows it's just the same "joke" copied over and over again...
That's exacly why they're jokes, why they're fine, and why it's still silly that pydis removes them; because they cannot do actual harm
Is docs.python.org a good place to learn python?
Harmful or not, the intention does not jive with the community we want here.
There's a tutorial there. I hear it's ok.
We mostly use the docs site for reference, when you need to look things up. Then it's extremely useful.
i;m tempted to say it could be instructive to understand the three (or more?) different reasons it won't work
Then, frankly, I think the orwellian nature of that desired community is a stupid goal lol
The door is over there. 🤷♀️
Classic Pydis, "your opinion is wrong, leave"
They're not fine. Wait for an unwise person to "fix" your joke, and then bad stuff happens. They're just a bad idea all around.
You can read it how you like. I'm saying your opinion is valid, don't subject yourself to such stress.

it's orwellian to stop people spreading malicious software?
No, it's orwellian to stop them posting jokes which, as we have established, aren't actually harmful because they cannot possibly run successfully because they don't work
have... have you read 1984?
It's one of many places. You might also like realpython website, our !resources tag, and books like Automate the Boring Stuff or Byte of Python. All depends on what provides you with what you need.
george orwell definetely wrote about this in his hit novel 1984
Here's a gun. It has no bullets. it's just fine.
I'm not against moderation, I'm against the misconstruing of jokes as potentially harmful when it takes a huge amount of effort to go from what was posted to code that actually can break stuff
We've always been at war with PHP.
Depends on who pastes is, the quotes aren't always converted to smart quotes...
Backslashes will work here - just show a warning - because \W and \s are not valid escape sequences...
So it's only os.remove not handling folders - and only when that gets fixed, we'll see permission error.
shutil.rmtree is hard work?
Last I checked, a program running normally in userspace won't remove system32 even if you use the right method.
And we always will be.
I'm confused how someone who has read the book could possibly think that telling people not to post commands that look harmful is "Orwellian"
if someone knows about shutil.rmtree and wants to modify that program to use it... 
Ok sorry jeez…
It wasn’t even potentially destructive then
There were actually cases of that when there was no staff nor old regulars to cut it off - people just trying to impress each other with actual closer to working malicious code...
I wasn't referring to a specific thing, I was referring to the general overbearing pydis approach to moderation in which everything is overscrutinised and responded to often disproportionaly, in my opinion
ok. That's not what "Orwellian" means.
When type hinting class attributes, should I use the most concrete type possible (as I would for function return types) or the most abstract type possible (as I would for function arguments)?
My bad, let me rephrase, "I believe the approach taken here is poor community management" instead then
Is the class an concrete class or an abstract class?
Meanwhile just earlier today: I asked someone to open any terminal and they opened admin perms powershell without me asking for admin... I actually told them never to do that as they may break something even by accident because of those elevated perms
i would say bring it up in #community-meta but...
(I do appreciate calling out the 'orwellian' thing, I would rather be correct in my phrasing/anaologising, I just also don't want that to be a detractor from what I'm trying to say)
Concrete
Then you'll want to make your annotations as accurate to the implementation as you comfortably can.
It's really a choice between list and Iterable. But now that I think about it, I should probably be specific.
-# After all, if my principle is "as specific as possible" then why not "Any" for everything, which is not helpful.
wrt. policing commands that appear to be malicious, there's two aspects that come into play. One is that this community has a ton of beginners, and beginners are known for pasting commands they don't understand - which is why we don't want people sharing things that would cause harm if executed. The other thing is that things that look harmful at a glance and require people to figure out whether or not they're actually harmful are a drain on our very limited moderation resources. It's harder for us to moderate if we need to treat looks-harmful-and-is differently from looks-harmful-but-isn't, and it's much easier to just say "don't share things that look harmful"
this is a better topic for #community-meta than for #python-discussion though.
But officer, it wasn't a real gun.
it's just a joke, bro
😝
wsg bad bitches
I want to add a toggleable overlay for a plugin I'm making but I want it to impact performance to the least degree possible, what python option should I use 
Any is the opposite of specific, isn't it?
really depends on how you want to interact with the data. if all you need with the iterable is to iterate through it, then that would suffice. if you need other things in list, then list
"As abstract as possible" is what I intended to say (I've been at this for awhile)
Ah, I see. Yeah, for that just don't use annotations. 
Can you give us some examples of that class attributes you refer to? I can think of both cases (concrete and abstract) being valid.
I mean, it's a dataclass so who am I to say how the data is used (what if slicling is something that is needed at some point)
you know what the data represents, no?
sup
so you want a gui for it basically @lusty spoke
Indeed, but I'm looking for more general advice (which in this case I guess is "whatever makes sense")
Is “pydis” an overloaded term? Beyond a python disassembly library?
It also refers to this channel.
isnt it python discord
@dataclass
class ShoppingCart:
items: list[Item]
Here I use list because I expect my shopping cart dataclass to contain a concrete list, instead of something like an iterable that fetches something dynamically (or whatever)
But I can imagine other use-cases where you may want to be as abstract as possible. I think it depends.
#bringbackpygen
Pepperidge Farm Remembers
Ah. Someone above seemed to be using it as a “python ‘dis”, as in “disrespectful.
✨ Language ✨
@dataclass(frozen=True, slots=True)
class FilterGroup:
target: str
filters: list[Filter]
@classmethod
def ofType(cls, target: type, filters: Iterable[Filter]) -> Self:
return cls(target.__name__.lower(), list(filters))
-# Don't ask why I need to store class names. It's the culmination of a number of bad decisions that I'd rather just keep running with than making the objectively correct choice of fixing at this point.
Though, given that I'm literally converting to a list… it probably should be a list and not an iterable
I wouldn't use a list with a frozen class but that's just me. I don't know that python will stop mutation of FilterGroup.filters.
Good point, should be a tuple then?
Does order matter?
just don't mutate it
Well, a tuple would be the frozen alternative. A frozen set if Filter is hashable and order doesn't matter.
Now I'm curious, does a frozen dataclass allow mutation of a list attribute?
I'd rather have the assurance that order is preserved (and not have to worry about what counts as a duplicate filter)
is there any library out there that allows python to crosscompile to windows? I've been compiling with a windows VM so my friends can use my apps and its annoyin
yes
>>> @dataclass(frozen=True,slots=True)
... class Test:
... x: list[int]
...
>>>
>>> z=Test([])
>>> z.x
[]
>>> z.x.append(5)
>>> z
Test(x=[5])
>>>
Hey @torn viper!
Add a py after the three backticks.
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
That they do.
My head, right now, does't like this but I'm also certain I've allowed this before in things I do.
src/trackbear_api/models.py lines 291 to 292
work_ids: list[int]
tag_ids: list[int]```
Huh i've never thought about using mutable things in frozen dataclasses. maybe because my only usecase of frozen=True is to make it hashable, which makes using list in it impossible
And yet, isn't that frozen dataclass hashable by nature?
I don't exactly know how Python could be setup to disallow it (or more broadly, disallow mutating elements of properties of frozen dataclasses, especially given that you could nest those element arbitrarily deep in the dataclasses' properties)
-# Probably dataclass' instead of dataclasses'
hashable dataclasses need to be frozen, frozen dataclasses dont need to be hashable
-# iirc
It couldn't. It's chasing something better provided by a more strict language. I just find it neat that I've never stopped the think about it. Or, at least, I don't recall doing so.
hello everyone im looking to start learning python does anyone know where is a good place to start thank you
Interesting.
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
!e You've seen this, right? ```py
t = ([1, 2, 3],)
try:
t[0] += [42]
except Exception as exc:
print(f"Caught exception: {exc}")
print(f"{t=}")
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | Caught exception: 'tuple' object does not support item assignment
002 | t=([1, 2, 3, 42],)
Fair enough
Yup! Love that one as an example, actually.
thank you very much
one of my favorite Python weirdnesses
wait a second...
To me it makes sense, since it's no different than in a langauge like Java writing:
final List<int> items = new List();
-# It's been awhile since I did Java, so I could have the grammar wrong there.
I like the idea of a frozen dataclass. Python gives me a "close enough" solution. I roll with it, and then get pointed to neat things like this in hindsight.
That and anything hashable can be used in sets and I use sets a lot.
Set operations make things go brrrr
this is java?
t[0] += something behaves like t[0] = t[0].__iadd__(something)
We need a deepfreeze, like deepcopy.
Yes? At least close enough.
-# Replied to teh wrong thing
Maybe some sort of system to check on that permission as well. You know, to make sure if we are changing something that we have the right to do so.
pretty sure given all the new frozendict discussion, this isn't possible?
Yes? At least close enough.
Also seems against python ethos
its just the wrong language if u want privacy like that
What is the proposed behavior of a frozendict when it holds a mutable and that mutable is mutated?
Whats deepfreeze and deepcopy?
I would assume it's mutated?
I do agree that at some point you cross over a boundary and the request of the system exceeds what it should be able to do.
At least I'd assume it would be to dict as tuple is to list
its muted, and if the frozendict contains something that isn't hashable then trying to hash the frozendict frails
I would guess that as well, currently. Haven't read the chatter on frozendicts
why are all objects heap allocated in python
bc its interpreted?
that is python's conceptual model
being interpreted doesnt stop a language from using the stack
deepfreeze doesn't exist. copy.deepcopy will make a copy of a mutable object (like a list or dict) and copies of all nested objects within it. Versus a shallow copy.
i guess, but wouldn't objects going on the stack require them to be immutable?
I guess a fully slotted class could go on the stack
no
Python can't do the kind of analysis required to guarantee an object allocated on the stack would actually have no references when the stack pops the frame
if you can add arbitrary amount of size to an object, how can it safely go on the stack?
And the internals don't allow relocation to try and mitigate this
just don't deallocate it 📈
stack_ptr -= (whatever the size of your value)
by having it reference something heap allocated
i would assume any language that does reference counting couldn't put their stuff on the stack 
at least not without some way to copy it to the heap after the fact
Recently Python even moved parts of the call stack off of the conceptual assembly stack
that doesnt make sense.... reference counting could be for dynamic things like arrays, or values that need to stay alive until they are no longer used, and everything else stays on the stack
Every object in Python stays alive until it's no longer used
yes i know
Guys I code with python since 4 years and I have no clue of what language I should learn next. I was thinking something like c++, c or go. Anyone got any suggestions for me
everything in any language should stay alive until it's not used 🥴
What do you want to build?
Are you suggesting implicitly unboxing values?
Depends on what you want to make
Pypy does do that afaik
but for example
x: int = 5
y: int = 10
what is stopping these from being on the stack?
there would need to be a lot of confusing pre processing to make sure every variable couldn't be that second case (values that need to stay alive until they are no longer used)
I guess they could just move it to the heap the second another reference points to the same thing, but at that point just put it all on the heap in the first place again :p
del x
ah
Usually my projects consist of high requests per second. So concurrency and high perfomance is my goal for a language
For local variables, pypy would probably unbox those. Maybe Pythons experimental JIT would as well
oh unbox like take them out of PyObject?
There's a separate optimization for ints where their instances are reused rather than allocated anew every time.
Yea
when you say "these", do you mean the integers or the variables?
Haskell? It might not be something you end up using (I don't), but I found that it rather changed my perspective on a number of things (and for that, I think that learning it was worth it)
Yea
But some "use" doesn't really mean used, but just hanging around forever. I'm looking at you, memoized methods 😒
(https://discuss.python.org/t/memoizing-methods-considered-harmful/24691)
That is "being used". Remembered for later.
Yeah that one's kinda obvious
sure. It's also a memory leak in all but name. Remembering something you don't need to remember any more.
like how js does it with like (not exactly)
struct Object {
ObjectType type;
void* ptr;
short small_int;
};
Why does this stop x from being on the stack? You don't need to make the used stackspace available immediately, do you?
stack space needs to be calculated at compile time
Pypy is a JIT, so I think it'd just straight up generate code that works with machine words and gracefully degrades to bigints if things go poorly
this would break the entire reason the stack is fast, the reason the stack is fast to my knowledge is 1: it's a cache hit magnet, and 2nd, there are no holes in the stack
ah
do you know that there is only one copy of 5 and one copy of 10 in the program?
Is that related to weakref? Why couldn't it (or my own custom memoize decorator) use wekrefs?
(to be clear, so would a real JS impl)
yes this would be at global scope in one file
no, that's not what I mean
Because two distinct instances could be equal, and so should provide the same cached result
Even if the first was lost before the second one was even constructed
I mean that even if you do ```py
x = 10
y = 9 + 1
z = int("10")
I could guess that
java does similarly with like strings
!e ```py
x = 10
y = 9 + 1
z = int("10")
print(x is y is z)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
True
nice
which means that if the integers were put on the stack, the program would use more memory, not less, and have less cache locality, not more
I believe you but I have a hard time believing it. So if I were to do x = random.randint(0, sys.maxint) it has to find an existing object with the integer value (if it exists)?
really?
there would be a cpu preformance hit because it has to go to memory to reach that pointed value, no?
If you consider the cache in a thumbnail service, keyed by say ("path", w, h), the tuple of a previous invocation would be long gone before the next invocation could happen given a weakdict (of course, functools.cache would be incorrect here)
no, this optimization only applies to integers in a small range, not the whole range of ints. -5 through 256 IIRC
ahh, ok 😌
it's the "small integer cache"
About 2: if you try to use the holes, sure. Otherwise i see no problem with del x just hiding x from the interpreted code but still occupying the space on the stack until it would have been removed as usual.
yea that makes sense i guess
the stack and the heap are both in memory, so it has to "go to memory" no matter what
ah
Do you imagine a scenario where Python would ever interns strings more aggressively for similar purposes?
Python already interns strings pretty aggressively, and lets you choose to intern strings yourself if you want something even more aggressive
but if on the stack this could be optimized to each using a byte of memory perhaps instead of the 16 bytes PyObject does on 64 bit systems
Ah, with a custom memoize I guess that could be fine.
sure. Historically Python had two different integer types, one that was arbitrary size and one that was limited to the size of the C int type on the underlying platform. That was removed in Python 3 because the CPU cost of all of the checks and conversions far outweighed the memory savings.
they checked at runtime?
Oh, I don't really see the current behavior as 'aggressive', more opportunistic/ low hanging fruit, as I understand it. I've never directly used intern... I know it's there, but somewhat wondered if it should be used more widely. Or perhaps it is in some libs I use, dunno.
It's not possible to check anywhere but at runtime
yes - you need to, because those two different integer types could both be passed to some function like sum or math.sin or whatever
Wait. Hmm. What does this mean actually? Why is this a problem?
A cache doesn't necessarily have infinite size, so it can't be to guarantee the function+args doesn't get computed a second time.
maybe, but even using 8 bytes of memory (sizeof(long long)) is a win over 16 bytes of memory
Functools.cache does, and a cache eviction strategy that's just "did the object live long enough" is probably rather ineffective
wait, it couldn't be 8 bytes of memory when you pass it to sum
The stack is no less in memory than any other variable. In most systems. No? (I'm not familiar with modern systems, nor mmu so I shouldn't make statements like this)
sum takes arbitrary Python objects. You need everything you pass to sum to be a PyObject* (or some similar discriminated union)
im saying if all integers on the stack used max int size
it wouldn't help, because it could still take something that's not an int
or an int that's larger than the limit of long long
so like 128 bit ints?
that works until someone wants to pass a 129 bit int
can python ints scale infinitely?
yes
even setting that aside, think of functions like print
Probably.
You can assume the sum is given only integers within the scope, construct byte code that assumes this, and when it turns out it's wrong, rewrite the bytecode to do the more general setup
print takes completely arbitrary objects
I can finally count all the atoms in the observable universe?
Graalpy and the new adaptive interpreter sort of do this
Tho I think they go general -> specific
hm
well so does printf in c
it's not really analogous, no
printf in C takes a format string that tells you how to interpret each of the things you've passed it
print in Python doesn't have a parameter like that, so print needs to discover for itself what type each argument is
in printf, the format string is the discriminator, in print the ob_type field of the PyObject structure is the discriminator
wow you know a lot about python
🙇♂️
It really doesn't care much. obj.__str__ FTW.
yes, sure
how does it know what obj is though? I think that's what hes getting at
but even so, the point is that it couldn't just take a long long off the stack
str is looked up on the ob_type
it needs to be passed something that tells it that the pointer it's been passed should be treated as a pointer to a long long and not to some other type of thing
yea
you can only get rid of the PyObject wrapper if you replace it with some other way to introspect the type
dynamic typing is difficult to optimize it seems
optimizations with types!!!
make the linting do stuff
The idea would of course be to implement everything a second time for long long specifically, and wrap it back into PyObject when needed. It'd be pretty nightmarish in practice tho
Graalpy does work like this
either that, or have a new base type of PyObject with an extra field saying whether this thing is a PyObject or some optimized type
or jam that directly into PyObject
problem with that is that uses more memory for all objects, no?
not for all objects, no
right now PyObject is at the biggest it should be because 16 bytes is just enough to be copied in one instruction
I mean, very easy example, you could make the ob_type field store a sentinel that indicates that this is some optimized type
yes, and reinterpret the pointer as that optimized type
like, if ob_type == 0x1 then the ob_refcnt field isn't a refcount at all but the value of an integer object
you can do this, and it would save space, but it would probably cost far too much CPU by littering special cases everywhere
there is no ob_ptr field
oh
like whatever points to the underlying object
PyObject is 16 bytes, composed of exatly 2 fields, each 8 bytes - ob_type and ob_refcnt
then where is the actual value?
after the PyObject header
all objects start with the same common prefix, and the ob_type field dictates what comes after that prefix (and before it, actually, because the gc sticks some fields before it depending on the type)
more or less...
the better way to think of it is that PyObject is a base class, that base class is 16 bytes, and subclasses of it might be larger
is PyObject a C++ class?
no, but its memory layout is very similar to one
Include/cpython/longintrepr.h lines 93 to 101
typedef struct _PyLongValue {
uintptr_t lv_tag; /* Number of digits, sign and flags */
digit ob_digit[1];
} _PyLongValue;
struct _longobject {
PyObject_HEAD
_PyLongValue long_value;
};```
the memory layout of a Python int object is:
PyTypeObject *ob_type;
Py_ssize_t ob_refcnt;
uintptr_t lv_tag;
digit ob_digit[n];
so this would work?
yep
that's cool, but how are these put in arrays?
that's more or less how a tuple looks in memory
it seems like it would be very slow to iterate over them, because you have to figure out each element's type, then increment the pointer by that many bytes
is that why for loops are slow in python?
you don't usually put a PyObject itself in an array, you usually put a pointer to it in the array
oh
would you prefer it if python used curly braces instead of : and indent?
Bython
!e
No. gah!
from __future__ import braces
:x: Your 3.14 eval job has completed with return code 1.
001 | File [35m"/home/main.py"[0m, line [35m1[0m
002 | from __future__ import [1;31mbraces[0m
003 | [1;31m^^^^^^[0m
004 | [1;35mSyntaxError[0m: [35mnot a chance[0m
I heard python for loops are slow, is that true, and if so, why?
it's one of those things that seems to be most identified with python
because python is a stack vm so it pushes and pops and decref/increfs the refcount of each object in the for-loop
subjective but I think most people would say otherwise
Are you interested in what you're building in python?
If you're coming from java, less is spelled out overtly in python.
please elaborate?
ive met several people who say that, and it seems fairly arbitrary
why?
like a Python list is basically ```c
PyTypeObject *ob_type;
Py_ssize_t ob_refcnt;
Py_ssize_t ob_size;
PyObject **ob_item;
Py_ssize_t allocated;
ah
the question is always "compared to what?"
not compared to anything, just anything about python's implementation that might cause preformance issues to occur in for loops specifically
if you're comparing to C loops, it's apples to oranges. C loops know that they're only dealing with integers. Python loops can deal with any type of object, so there's overhead involved in figuring out what types of objects they're dealing with
Python's interpreter is a stack machine, and it executes bytecode.
The interpreter reads the bytecodes, and some bytecodes push values onto the stack and some pop values onto the stack. Because of the pushing and popping, the stack owns a reference to the object and it has to increment the refcount and decref it when it is popped of the stack, so there is a lot more overhead. Not to mention the dynamic typechecking which adds evern more overhead
like for for i in [1,2,3,4,5]?
in Python you can do for line in file: or for elem in some_list: or for number in itertools.count():. That abstraction isn't free, and since Python is an interpreted language it doesn't know until runtime what type of object it's actually looping over
i mean yeah it's slow ig
that should hopefully improve once the JIT gets better
so to optimise python you got to assume types
and then fallback if that assumption fails
also the gil is being removed, what is it being replaced with?
it's not being replaced with anything, it just allows for free-threaded python, afaik
then how are race conditions avoided
the gil is one big lock. It's being replaced with lots of small locks and lots of atomic operations
ah
where do they put the locks?
everywhere 👀
like what gets wrapped in a mutex
but in particular, in free-threaded builds, every object contains a mutex for locking access to that object
ah
and there's other types of locks, too
so is that in like the pointer to the pyobject or the pyobject itself
in the pyobject itself, I believe
ah
Include/object.h lines 156 to 167
struct _object {
// ob_tid stores the thread id (or zero). It is also used by the GC and the
// trashcan mechanism as a linked list pointer and by the GC to store the
// computed "gc_refs" refcount.
_Py_ALIGNED_DEF(_PyObject_MIN_ALIGNMENT, uintptr_t) ob_tid;
uint16_t ob_flags;
PyMutex ob_mutex; // per-object lock
uint8_t ob_gc_bits; // gc-related state
uint32_t ob_ref_local; // local reference count
Py_ssize_t ob_ref_shared; // shared (atomic) reference count
PyTypeObject *ob_type;
};```
yep
every object
ah
PyObject is a typedef of struct _object
im a complete beginner
I tried python first it was too hard, then I tried java and found it easy
ppl told me python is simple
it's about as easy as java
public static int add(int a, int b);
this tells you everything you need to know
def add(a: int, b: int) -> int
these types are optional in python, which means you sometimes just dont know
nah
I think that's the reason
one possibility is that you found Java easy because you had already learned some Python. You might have found Python easy if you started with Java and then moved to Python. You might just be discounting all of the stuff that's common to both languages and which you already learned while trying your first language
Usually is.
the biggest part of learning to program isn't learning any specific language, it's learning concepts - what's a function? what's a variable? what's a loop? how do I read this error message? - and a lot of that is common no matter what language you're using
yeah in college when we code with python it's in stuff like Webot which I'm not interested in and I don't understand, but when we code in java it's stuff small window applications, many console-based programs etc etc
so ig I associate python with hard stuff I don't understand
which year are you?
it definitely is much easier to learn if you find what you're writing interesting
1
god I wish they teached us stuff we'd need in the future 😭🙏
They do. They teach you how to learn.
I don't get why this "webot" thing was even there in the first semester
okay
you just need to get past the introductory stuff
hey, wait - I let this slip by earlier, but this is wrong. It does care, because the type is the thing that holds obj.__str__! You can't get the __str__ without the type (the PyObject points to the PyTypeObject, and the PyTypeObject contains the tp_str field). You're right that it doesn't have, like a switch over every possible type, but it instead indirects through a vtable owned by the type.
aight
okay thanks for making me realize chat
for what it's worth, Python and Java are very similar languages, in the grand scheme of things. If you get good with either one, you'll be able to pick up the other one pretty quickly.
-# really?!
quite
ive never thought of python and java as "similar"
then again, i dont know java in-depth enough
Java is based on C
You could even say that Java is the father of Python
They honestly are
A lot of concepts are very transferable
Which I found incredibly nice
Except python is older, so that's weird. 
or return type of main
I think most Turing-complete languages are going to share many similarities
i dont think there's a concept of static in python?
Static methods?
static class
I didn't say that it would be accurate, only that you could say it.
or rather, static functions
that's what @staticmethod is, no?
You could say it, but I'd expect a willy-wobbly timey-wimey explanation for the age difference. 
!d staticmethod
@staticmethod```
Transform a method into a static method.
A static method does not receive an implicit first argument. To declare a static method, use this idiom...
A static class in Java is really just a scoping control
outside of a class
How would that look like?
Wouldn't that just be a function then?
-# yes ive just been listing each of the keywords from public static void main
mods, get her
Mods, mods!
wait what
Also, minor rant
But I actively dislike the "right way" to write Javadocs
Because what do you mean, I'm supposed to write @implsec on the documentation
Teaching people how to implement stuff is weird
Well in Java there’s no such thing as “outside a class.” There is no global space like in Python
correct
and so... i struggle to think of them as "similar"
there are so many differences between them
there's no list comprehension in java
Do you not normally write documentation on how to implement what you've designed?
I don't usually write them on the docstring
I usually do that on a separate document so I can easily share as markdown
never conform
I kinda get that Java is a lot more contract-bound and all that but, I don't find it great to tell people how to do things
But when in Rome, do as the Romans so
Whatever
The way I see it, even the function signature is telling the next-dev what to do. If it's any more complex than that, the instructions in the docstring only further helps the next-dev.
once i got to concurrency in java i was out
ugly looking code
still my first lang and has a place in my heart
for a video game funny enough that wasn't minecraft
A static method in Java is the same kind of thing as a static method in a Python class…… mostly.
for a private server 👿
Stream.parallel() or the ThreadPoolExecutor make it pretty easy tbh
i just dont get completable future chaining enough to not make it super nested
But Python gives you three scopes in a class, instance, class, and static. Java only has instance and static. I’m tbh I still don’t really understand the difference between a static and class method in Python, other than you cannot refer to a static class method via an instance reference, only via the class name reference, like Foo.my_static_method()
document like you are always working with a team, your team member might just be you coming back 6 months later trying to figure out what you wrote
@staticmethod could arguably be removed from python with no major loss (besides breaking existing code)
!e ```py
class A:
@staticmethod
def b():
print(1)
a = A()
a.b()
:white_check_mark: Your 3.14 eval job has completed with return code 0.
1
Well I was lied to! See, even the one thing I thought I knew I didn’t know
So what’s the difference then?
@classmethods accept a cls parameter
classmethod gets the current subclass passed
Static methods are methods that are organized with a class, and are passed nothing by default.
Class methods are methods that operate on the class, and are passed the class as cls by default.
Instance methods are methods that operate on the instance, and are passed the instance as self by default.
Not to confuse the issue, but a “static” method in Java aligns more closely to what you’d call a class method in Python
I don’t really get why static methods need to exist
static methods in Java know what Class they belong to
What what
Exactly.
https://mail.python.org/pipermail/python-ideas/2016-July/041189.html
Honestly, staticmethod was something of a mistake -- I was trying to do something like Java class methods but once it was released I found what was really needed was classmethod. But it was too late to get rid of staticmethod.
actually, maybe not quite...
Can you override a static method in a subclas in Java?
So static methods in Python seem to just be a namespace for methods.
does anyone have an article about how the L3 cache works?
On your CPU?
the general workflow of most L3 caches
Pretty much. A way to put a function in a class without changing it
No, you can hide them though by redeclaring a static method with the same name. However, they are not inherited and there’s no runtime polymorphism. The method to be executed gets bound at compile time, not run time, unlike with instance methods.
what happens if you call the Java static method from a subclass? it still refers to the superclass?
You probably mean the "shared cache", no? That's typically the L3 cache nowadays, but it doesn't have to be the L3 one
And that’s generally considered bad practice in Java, whereas in Python (and I think JavaScript?) it’s a useful feature.
It depends on the static type of the object
i don't see it being referred to as the shared cache
Static just belongs to the namespace while classmethods are class aware
you arguably can do static with classmethods anyway but like
eh
classmethods are much more powerful
It depends on the type of the reference variable you use. If you have a static method() in both class Parent and Sub,
@dry pike Java has two types for each variable: The static type and the dynamic type
If you do:
A variable = new B(); // assuming B inherits from A
variable.func();
```then the static type of `variable` is `A`, but the dynamic type of `variable` is `B`, so if `A` has a `static` function `func()` then it would call `A.func()`, even if `B` overloads it
but I mean, within the functin
because someone said that the function gets a reference to the type
the only like, actual valid reason may be semantics
Well, you know which class you're currently writing code in, no?
I assume this is what they meant (obviously then there's also reflection, but I won't get into that)
dude how do you read the pyrr documentation
It’s bad form to call a static method from an instance variable because of the possible confusion. So you would call Foo.aStaticMethod() from an instance method in the Foo class and never this.aStaticMethod() and then you will never be surprised.
i had to go to the source code to find what the parameters of a matrix creation function expect
!e
That's the difference between static methods in Java and class methods in Python then. You can do this in Python: ```py
import math
class Point:
def init(self, x, y):
self.x = x
self.y = y
@classmethod
def from_xy(cls, x, y):
return cls(x, y)
@classmethod
def from_polar(cls, dist, angle):
return cls.from_xy(math.cos(angle) * dist, math.sin(angle) * dist)
class LoggedPoint(Point):
@classmethod
def from_xy(cls, x, y):
print(f"creating a point with {x=} and {y=}")
return super().from_xy(x, y)
p = LoggedPoint.from_polar(425.63012111456584, 0.1628311844604171)
print(p.x, p.y)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | creating a point with x=420.0 and y=69.0
002 | 420.0 69.0
Yes, class methods can be overridden in subclasses. It’s nice. You can probably only do it in Python because it’s a dynamic language. Java resolves a lot of things at compile time so they are fixed in stone at runtime, whereas Python can happily redefine your foo:str variable to be foo:int at runtime. Now, the fact that you can do something like this doesn’t mean you should do something like this.
Substitution principle was respected in their example though.
LSP is kind of a handwavy thing
It’s an aspirational goal, not a roadblock
Is a square really a subclass of a rectangle? It depends.
Whether a subclass method is compatible with the superclass method depends on what promises the superclass makes. If the code has no docstrings or comments, one is often left to speculate what the intended promises were
a square has a restriction imposed on it that rectangle doesn’t have. Then again, a square can just be a degenerate case of a rectangle where width = height
I guess here's an example of where staticmethod is helpful:
class Shape:
@staticmethod
def compute_area():
raise NotImplemented
def area(self):
raise NotImplemented
class Rect(Shape):
def __init__(self, width: int, height: int):
self.width = width
self.height = height
@staticmethod
def compute_area(width: int, height: int) -> int:
return width * height
def area(self):
return self.compute_area(self.width, self.height)
data = Rect(5, 5)
if data.area() > Rect.compute_area(5, 4):
pass
i'm having fun with SIMD
What's the point of having a compute_area in the parent?
To raise if the subclass is improperly implemented. Could be an ABC but I didn't bother
Collecting numpy
Downloading numpy-2.4.1.tar.gz (20.7 MB)
━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.8/20.7 MB 18.5 kB/s eta 0:17:56
WARNING: Connection timed out while downloading.
WARNING: Attempting to resume incomplete download (786 kB/20.7 MB, attempt 1)
Resuming download numpy-2.4.1.tar.gz (786 kB/20.7 MB)
━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.8/20.7 MB ? eta -:--:--```
what the fuck is my ISP on
Yes. I was missing the cpython internals side of this discussion and the "how much info do you need" from that point of view. I was more going: print itself doesn't really care about which type, as long as it can indirect throuugh it to the __str__ method. Which is largely why I then shut up 🙂
Fair enough. It's less.. dynamic. Things are quite explicitly spelled out.
18.5 kB/s
What year is it
It's 1995. I'm getting 18.5kb/s on a download over my isp via dial-up
It's 2026. I'm getting 18.5kb/s on a download over my isp
148 kb/s in 1995 was probably very good
!e
from datetime import datetime, UTC
print(datetime.now(UTC).year)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
2026
2026 and im still geting these speeds over ethernet
they genuinely have something against me icl
We used to see that throughput on ethernet when one side was half duplex and the other full duplex and they were thus mutually misconfigured. A recipe for packet loss (and thus appalling TCP retry behaviour).
Ah, the modern pleasures of gigabit and full duplex and no crossover cables.
18kbps was pretty good for dial up. ISTR that trailblazer modems would achieve that, and not much else. At one point, anyway.
wait you can get 11Gbps in some places now?
oh god nvm, 50Gbps
that means you could (theoretically) download 1TB of data in 160 seconds
Python and Java are both high level object oriented garbage collected imperative procedural algol-derived languages where objects are passed by and assigned by reference. And both are compiled to bytecode and then interpreted by a virtual machine. They're very similar in the grand scheme of things. Both of them are much more like each other than something like Fortran or even something like C
Enterprise gear is over 100 now
I didn’t think anything over 10 had trickled down to consumers yet though
yeah this is consumer, Ziply Fiber that I found online
I assumed enterprise stuff was much higher since a while ago
Can I just like, live, in the data center?
All I need is a sleeping bag
I just want the Ethernet cable
You will want earplugs or ANC headphones.
That’s okay
And a warm coat or something.
Better than CO2 extinguishers.
certain spots are not so bad in a dc.
Do I inhale or exhale first?
Best to inhale before they go off.
having to stand in a cold aisle does suck after a few minutes.
Yep. If you have a good local link, ethernet is faster than most ssds.
what if we put fiber in da PC
you can do that
lemme guess it's so expensive that no one makes those
50$
?
Amazon has a bundle: PCIE card to SFP, SFP transceiver, 3.8m cable for 48$
of course, you need a router, and probably a longer cable, but like
why would you need a router
Well, because this replaces ethernet?
oh
It's a NIC. Replaces an ethernet NIC.
Yeah, and a fiber cable, replaces the etehrnet cable
I went looking for "optical sata" and didn't get what I wanted.
Fiber within the pc isn't worth it. Too many turns and you're already electrically so close the translation between light and electric isn't worth it
Unless it's all optical.
COnversion will.
Someday there will be functional optical transistors on a mass scale, but that day is not today
that's what I meant
do you think we'll survive that long?
Probably? Like, I'm gonna be real, if we die it'll be self-inflicted. Modern crops and fertilizer techniques aren't going away and could resurrect us even after most apocalypse scenarios. Despite the global economic chaos, "Everyone is gonna die" isn't particularly realistic. It's hard to kill an entire species. To clarify, if the US set up a relatively small array of modern nuclear reactors, it could reverse the flow of the mississippi river and desalinate all the water needed.
As for individuals, idk. Depends. A fucked up political state can last a few centuries, but the internet has kind of changed everything (and with the advent of mesh and ham networks, isn't going away ever)
between 150 and 200 species go extinct every day.
And there are trillions of species on the planet. As bad of an ecosystem disaster as it is, there is a big difference between a disaster and obliteration.
You can think of it in terms of nines of uptime/reliability
I don't know what "nines" means
I had to search if this is true, and it is... this is depressing
99.9% (3 nines) uptime is 8 hours of downtime per year
99.99% (4 nines) is 52 minutes of downtime per year
which is 3 9s.
99.9999% (6 nines) is 32 seconds of downtime yearly
It's estimated there are about 8 million species on earth. 99.9999% of 8 million is 8 species lost per year
I think a puzzle site I play on has about 3 nines scheduled
Now there's a lot of impact variance. For example, there's a lot of species of bugs and bacteria that are not as striking as losing big cats or rare birds.
But to drag this back to humanity
justice for small cats
At one point in history, it's estimated there were about 1300 humans left alive.
the world was so close to healing
To get there from today, 99.9999999% of humanity would need to die
nine nines. That's just intrinsically difficult. Not much in reality can be that thorough. so, no, I don't think there's a concern there in a "wipe out" moment. Same with regular cats and regular dogs.
Just learned that 99% up time equals to 3d and 16h cool
catastrophic events to large-scale environments can occur when a single species disappears
I'm not a biologist and I don't understand anything about biology. Why are you bringing those numbers? What is your point? Is it that humanity is close to extinction?
This all came from NWJ asking if we would live longer enough to see all optical computers.
No. It's that humanity is very far from it.
It also relates to optical computation as it exists today
A modern CPU has a bit error rate somewhere south of 1/10^12
apparently quantum entanglement is not instant
or 99.9999999999% accuracy
If you want to compete, then optical transistors also must reach that error rate, which is (IIRC) one of the main struggles today with that and quantum chips
99.9999999999% (12 nines) is 0.32 milliseconds of downtime per year
sorry, that was the formation of the entanglement
My blog is six nines, roughly
discord.. significantly less
github less than discord
how much work did it take to get your blog to 69s?
coming dangerously close to six sevens
Not much. A stable framework, nginx, and then hosting it on a vps instead of a cloud service.
micro, not milli
32 millis is 9 nines
if your downtime is close to six sevens you should be reevaluating your choices
the 3d printing website thingiverse is infamous for being constantly broken. there's a joke their uptime isn't 5 nines, but 9 fives
huh, not usually the case where one can pull an "i saw that" on nedbat
yurrrr
good morning (again)
my website is up for 9 zeros
well depending on what website wer'e tlaking abuot
that's too high. make it 12 zeros
if my website is hosted on say, cloudflare, and cloudflare goes down, how could i switch over to aws programmatically?
what do you mean by "hosted"
change dns record?
say i deployed a static page to cloudflare
just a simple html
my dns provider is also cloudflare, how would i change my dns record if cloudflare went down
you can't
Are you looking for a DNS failover solution?
wait, does this mean i have a dns setting that automatically switch over to a secondary host if the primary host goes down?
More or less. Load balancing.
or does this mean when the dns goes down, a secondary dns takes over
I'm confused by "dns goes down".
Half of the states are no longer online.
my website worked just fine, it was on aws
You want a multi-cloud solution?
im not sure what the definition is
i guess if you want a service to survive these kind of events, you basically need to be the nameserver?
It sounds like you want load balancing (or whatever name said service calls it). Mutli-cloud just means you're using more than a single cloud provider. To your "what if cloudflare goes down"; there are 300+ cloudflare datacenters. Not all of them go down at once. If all of cloudflare disappeared, nobody would care your website was down. Least of all, you.
i can imagine having my website hosted on vercel (and by proxy, aws), cloudflare and on-prem, and then just having the dns failover to the secondary and tertiary host
but if the dns nameserver goes down theres basically nothing you can do?
The DNS host that can change the route needs to be somewhere.
it's not possible to have my records on both the google nameservers and the cloudflare nameservers, right?
If all of cloudflare disappeared, nobody would care your website was down. Least of all, you.
this is just an hypothetical scenario
Hypothetically, that is a freaking doomsday situation. 
im not actually going to spend the engineering effort to ensure my little site survives internet catastrophes
this is all just academic discussion
I don't understand networking enough to answer this correctly.
i dont even know whether my question even makes sense
turns out it is possible, but it's only for enterprise customers
at least according to an answer in here: https://community.cloudflare.com/t/can-i-use-cloudflare-when-domains-nameservers-are-pointed-to-google-domains/345284
🤷♀️ I think I know what you're asking. But take the AWS us-east-1 dynamodb issues that took down a chunk of the internet for a day. The takeaway for corps there wasn't that they needed a multi-cloud solution. They just needed to use what they had more correctly. ((multi-region in the case of aws))
So maybe work on being resilient to failure in your cloud of choice. Once those patterns are understood you can tackle the increased difficulty of a multi-cloud solution.
my surface-level understanding of nameservers goes like this: if i request for say example.com, and their nameservers is cloudflare, my computer first gets directed to cloudflare dns to ask for the IP address, and then it gets directed to that IP address where the site is hosted
so what if the cloudflare dns goes down?
suppose i need this service to be like crazy resilient
The world cries.
Anyone dependent only on them is stuck.
Most people have a few.
have a few?
Eg 1.1.1.1 (cloudflare) 8.8.4.4 (google) and etc
it's possible to have your records on multiple dns nameservers?
I'm talking about the upstream nameservers a client like your laptop might use. On UNIX, the /etc/resolv.conf file.
well, my primary is cloudflare, my secondary is quad9
There's 2 sides to this: who your client/laptop asks, and who hosts the zone file (the names/ips in some domain like example.com).
so if cloudflare goes down, will i still be able to access my site through quad9, which i have registered on cloudflare?
Define "goes down".
So my laptop here's using:
search wauk
nameserver 172.16.3.1
nameserver 1.1.1.1
at present. The 172 address is my home firewall/dns/dhcp server.
The 1.1.1.1 is cloudflare.
cloudflare dns servers borked
Zones are usually hosted on multiple machines/services also.
i dont actually understand zones yet
i should probably look into it
It's the collection of records for a domain.
so i can host it on multiple services?
i can use both cloudflare dns AND route 53?
turns out yes
and this is quite commonplace
Pretty sure. The parent zones have NS records for the machines which can answer questions about your zone.



i see
today i learnt
NS == nameserver
Nobody mentioned rust. Go back to waiting for your cargo build /j
So when you talk to a public service like 1.1.1.1 it in turn talks to other DNS servers to get your answers. There's lots of caching.
cant open discord when rustc is running
OOMs
More swap.
Just buy more memory.
Or fast disc.
in this economy???
I don't even write rust
I know, right
. It hurt so much.
@mods is this true?
TIL route 53 is called route 53 because dns port is 53
Just wait until you learn why boto3 is called boto.
idk, why is boto3 called boto
Why is GNU called GNU?
🐬
Can you enlighten this ignorant user here? (me)
boto is apparently a species of bottle dolphin that lives in the amazon river, which is a play on amazon web service
Ah, thank you.
i used python for something that has made my life easier, and it is amazing (im very new to coding)
Any thoughts for making this faster? I want to try removing a directory, run a command, then put it back if it fails. Currently I’m using shutil.move + tempdir.TemporaryDirectory, but it’s very slow for large folders. Any ideas for speeding it up?
rename the folder to a temporary name?
Python too hard bro
Sweet! What'd ya do?
wait does shutil already do that
Hm, that might work? My main concern is it wouldn’t if the folder name doesn’t matter to the program being run (in this case it’s ty)
i see
hmmm
idk whether it would work but i would try adding a pattern with https://docs.astral.sh/ty/exclusions/#excluding-files
maybe ignore all **.temp.**?
i work at a car dealership, and i have to make facebook ads (no i did not make an auto fb ad maker and am not advertising 😭) but it just scrapes info from my companys website using selinium, then i have a little qt gui that comes up and it fills in the answers for the fb prompts, and it also downloads the listings images so theryre easy access and i experimented with threading for the first time, and it made the scrapping go from 2 min to 20 sec, and it felt like i waas einstein, and i made the gui really pretty took me like 2 days, all around went from taking 20 minutes to making a fb add to 2 min, i just have copy and paste boxes for the writable stuff
its not automated just makes life easier
🎉
That's kick ass, actually.
Ooh, that is an idea. Similar would also be like adding a command line config for forced ignoring a file, though that would be hard to persist
Either of these would also make it easier to re-run, since it things go wrong it’s quite annoying having to unzip a 1 gig zip again
its made my life so much easier and i am so happy and proud of myself
bribe the mods to make you a staff
You can’t, at least for this channel. You can post images in any of the off topics or in the help post channels though (though also please don’t dox yourself)
i was just gonna show img of my programs gui
you can send in #ot0-psvm’s-eternal-disapproval and just link the message here
thankyou i put them in there
Gaming, what ui framework did you use?
pyqt5
Hm, I might have to push that up my list of ones to look at from my project
emojis make everything look better😎
(For those in the know I still haven’t pinned down what to use for my regex visualizer ;-;)
it auto opens my dealerships page, aswell as my fb, and it saves the cookies for my fb, and also has a feature to delete those cookies its amazing
my eyebrows raised instinctively when i heard that
i just wasnt about to format my own images and spend another hour or two, aligning everything easier to just type it out 😭
so emojis on top
i guess im too boring a person haha
Though I did have an idea for making a backend-agnostic easily transpilable gui framework, does this sound completely insane or semi reasonable?
It would be immediate mode, based around only percent-based or absolute positions (so no flex boxes) layouting outside-in
i also just sent a photo of what it looks like when i input a url
the cycle took 14 secounds to pull all the data
how many pages?
And use an imgui-style draw list for everything in the backend made of primitive draws/text draws for the backend agnosticism
A GUI framework without Flex boxes would be kinda useless tho?
it pulles one listing, i downloaded 20 images, ran all the info in open ai to get a description, and pulled all the web data for the info to fill in things, it could prob be faster but im happy with it for now
i see
i guess it's way faster to code it like this
500 ish lines
im also very new to coding
i started learning python maybe 4-5 weeks ago
oh wow that's impressive
That’s one of the main things I’ve been thinking about with this, since I really like immediate mode, but that makes flex boxes basically impossible easily, so my idea is to have inside out layouting using only absolute positions or percentage based sizes which should cover my needs, since I don’t see myself needing flex boxes for most of my uis
If it works for ya, cant say much about it
I have written a layout engine and yeah, flex boxes make things tons complicated
my job said i was alowwed to spend time doing anything that would help me sell more cars, i have been spending atleast 8-12 hours a day learning to code for the last 35 ish days 💀
Immediate or retained?
my brain hurts beyond belife
Wow am learning new patterns from copilot suggestions
hope they aren't antipatterns
Don't use AI for that, you might learn antipatterns
Writing code like an llm is not desirable skill to have
Ah but they are quite easy when i think about it.
Like its inserting to a db. I thought of dumping everything at once or one by one
But it suggest to make it into chunks which is better for network calls
But you could filter out and learn the good things that it gives right
how would you know that they're good?
You dont know whats good as a beginner and ai loves to hallucinate and gaslight
ah like some sorta feeling.
For example here making many network calls to supabase db was bad right
but why would middle ground be better?
That feeling is called intuition and you get that from experience
Yea thats correct. Not believing it entirely
Ideally dont really use AI for learning, take stackoverflow or other resources
Like it process in batches. So like number of times the loop runs becomes less
Batching isnt always faster
by that logic, wouldn't running it only once be faster?
But i have a json with like 20k lines from which am inserting. Would that work like one http request can have that much stuff
that's probably quite within range of default limits of the web server you are interacting with
you think they would block one large request and not a bunch of chunks of the same data?
Yea
the chunks take more resources to deal with
So i have to time.sleep it ?
Ok I will try. But this what copilot suggested
os.rename ? should be instant if you just move things sideways.
but you had no reason to trust it
😅
Is that not the same thing move does?
Well I'd have thought so, but yousaid it was slow.
A cross device move involves a recursive tree copy, which would be slow. But on the same fs? Just a rename of the top dir3ectory should be immediate.
I don’t that that matters for this, but that is actually a good thought, since in one of my setups the default tempdir behavior would make the rename cross-drive
You can tell TemporaryDirectory to put the directory in the same directory as the thing it will be replacing. If you're doing what it sounds like you're doing.
But then it would still be discoverable
With eg listdir? Yes. But it will be unreadable IIRC (at least by people who aren't you).
By the program being run (ty in this case)
It's not clear to me what your use case is. I've got an atomic_filename(target_filename,.....) context decorator I use to make files atomicly. Make a temp file, write to it, rename to the target file is nothing goes wrong. And I've a similar thing for directries.
If the temp file isn't named like a file ty cares about, it shoud ignore it.
Sorry, temp dir. But the same applies.
I don't know ty's habits, but most things won't bother examineing dot names (.foo)
Hm, would module discovery still happen if the file was renamed
Again, I don't really know what you're doing.
If you need to import stuff, having the right dirs in sys.path does the trick. If you're doing something else, provide details.
Hello
Minimizer, trying to remove as much code as possible before the whatever issue in ty stops happening
I am a Python script developer
So:
- move something away, try ty
- repeat until happy?