#python-discussion
1 messages Β· Page 506 of 1
i know the difference between parameter and argument it just takes cognitive effort to me to distinguish
chopping wood?
cracking was changed to hacking, and now we all call it that
:p
right down to a single person going out of their way to correct the phrase "comprised of" on thousands of wikipedia articles, heh
Those Wikipedia editors are worse than Stack Overflow editors
there are so many examples of shifts if you've lived long enough to see them in action.
arguments vs parameters the people that know the differences are exactly the people that are able to judge context to figure out what the content means
"reticent" used to mean "reluctant to speak" but now people are using it to mean reluctant.
it means reluctant now.. i missed that
you'll hear it.
For example, the computer creates a "pick batch" to "pick" a "batch" of boxes from the warehouse.
So far so good.
Then for shipping, we scan the boxes, and print standard shipping labels in the SSCC format
https://en.wikipedia.org/wiki/Serial_shipping_container_code
But according to my shipping clerk, thats the "pick batch label"
No such label exists
The SSCC label doesn't reference the Pick Batch, its a whole different section of the system.
Clerk emailed support, support sent the email to me and said "we don't label Pick Batches..."
even merriam-webster has it: https://www.merriam-webster.com/dictionary/reticent
I only knew it to mean "reluctant" π³
smh, kids these days π
π
I guess I'd have said it had a connotation of "shy", but I wouldn't have thought it was limited to speech
TIL
I've only ever heard that word like once
When I saw it my brain filled in "recant"
I apparently remember it as someone wanting to back away from something
til reticent
i was a very reticent young boy when i grew up.
norwegian has its own word for reticent and reluctant as wel, where you would use reticent more often
I always thought reticence meant emotional reservation
Oh I actually have a perfect example relative to the above issue.
For some reason a box in inventory is called a "caselot".
When they come in, the receiving team prints the "blank goods label".
When they go out, the production team prints the "finished goods label".
They're both caselots in inventory, it would cost $0 to just consistently call them caselots and it would save tons of confusion for every new temp that thinks they're different.
Aside: my CEO calls both caselots and SSCC(s) "cartons" but that term doesn't actually exist on either entity, so that's yet ANOTHER term
I know it looks super nitpicky to make a big PR changing it all
But being clear helps so much
Starting to sound as bad as most big tech companies and their acronyms
Oh man, don't get me started, I won't stop...
There's a page where the same entity is referred to by three different names
Back when I was still bright eyed and bushy tailed I tried to make a glossary
By the end of the day I was crying
PBI
Power BI
Product Backlog Item
That's probably the most tame..
ML SEE
S.I.I.
(both referred to as "SEE", but one of the VPs wanted us to spell the acronym verbally)
All I know is that SII is Siri and Information Intelligence.. (this is actually on their jobs page, so I can repeat it)
And what makes it worse is that both used to be in the same org, under the same VP/SVP, and they only made ML SEE like half PMs and they really should've been PMs under SII..
good evening!
Howdy
hello
I think I had a stroke reading that
Hello
Hi
You'll never take my TLA's away from me.
TLA : TLA ~ girard's paradox
Hi
hey hey
guys how do i genuinly learn python, i have been trying for a month now
Clarity is key, I think that if parameters and arguments are different things, then the words should be used precicely to refer to those respective things
!sloth
there's loads of resources here designed for beginners
Here are the top free resources we recommend for people who are new to programming:
- Automate the Boring Stuff β an online book (also available to purchase as a physical book)
- Harvardβs CS50P course β video lectures (slides and notes provided) with exercises
- Python Programming MOOC 2026 course β text-based lessons with exercises
- Corey Schafer's YouTube playlist
For a full, curated list of educational resources we recommend, please see our resources page!
got it, thanks
I recommend "Automate the Boring Stuff", it's a book designed to teach Python, and is suitable even if you have no programming experience whatsoever. You can read through it online for free at that link above
TYSM
No problem, you can always ask any questions you want here. People here are really helpful
did you read the pull request I linked to? It's not always clear which is the correct word, and where it is crystal clear, it's not that important to get it right.
Is this a keyword-only argument or parameter: def f(*, a=1). That line literally defines the parameter, but it dictates how the argument must be provided. So is the topic arguments or parameters?
keyword-only parameter I guess?
a keyword-only argument would be an argument with only keywords?
Maybe I'm not understanding what you're meaning
if i were to be really pedantic i would say that "keyword-only argument" does not make sense because a given argument is either passed positionally or by keyword, it does not make sense to say "only" since its just 1 thing which is one or the other
but that is if i interpret argument as 1 specific thing in a given call expression
I think some of those changes being made are overly verbose though, if it's easier and simpler while still providing the same amount of clarity then it should be done that way, but sometimes it needs to be clearer
the whole thing started with an issue: https://github.com/python/cpython/issues/133438
PEP 3102 and PEP 570 say Keyword-Only Arguments but they should say Keyword-Only Parameters because a keyword-only parameter is the parameter which only accepts a keyword argument. Actually, PEP 57...
sometimes it's not worth the effort to scrutinize all the proposed changes, and not worth the churn in the docs to change them.
I say that, but I also made this change: https://github.com/python/cpython/pull/94551
This was discussed here: https://discuss.python.org/t/slight-grammar-fix-throughout-adverbs-dont-need-hyphen/17021
(sorry if I haven't provided the correct metadata yet...)
https://github.com/python/cpython/pull/94551#issuecomment-1174822559
What is the meaning of these emojis... I am curious
Python cherry pick bot, probably?
cherrypick probably refers to the git cherrypick feature
Ooohhhh
bingo https://github.com/python/miss-islington/pull/1
Initial commit of Python cherry-picker bot
Is there a way to switch python version in ubuntu ?
A simpler way
It already came installed with 3.14 for some reason
ππβπ€ - A bot for backporting and merging CPython pull requests
So this is what it is
uv or pyenv
the pyenv is stuck at this dawg π
pyenv install 3.11.0
Downloading Python-3.11.0.tar.xz...
-> https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tar.xz
Installing Python-3.11.0...
patching file setup.py
Hunk #1 succeeded at 306 (offset -1 lines).
It already came installed with 3.14 for some reason
because Ubuntu relies on Python for some of its functionality. which is why you don't mess with the system Python.
compiling, I guess
uv should be faster since it has prebuilt stuff afaik
You shouldn't mess with me
You don't wanna mess with me
'cuz if you're messing with me, you're messing with some of my functionality.
Lmao. Reminded me of that song
how do i even make sure its running ?
see resource usage in some process monitor
should probally have some cc or gcc whatever subprocesses that are compiling python
it shouldnt take too much time if pyenv calls make -j so its weird that it seems like its stuck
No saar
Well as some of the comments point out you can't know every subclass statically, especially not if this is for a library.
Any reason you can't go the methods route?
I like the match case way π
and dislike that method one but really haven't actually used it in practice so kind of biased i am currently
one annoying thing about match case is the double indentation
At least i don't have to spam isinstance() per if-elif stmt in same indentation, so i see it as a win situation
to be fair its normally double indentation in all the languages i guess, now that i think about it
but in python indentation feels more important than in other langauages
(compared to switch case forexample, not a 1 to 1 comparison though)
indentations are cool π even braces/delimiters based languages uses indentations to keep code more easy to catch on a level
(even though switch-case is not the equivalent of match-case)
in C-family-syntax languages I usually see people not put the outer indent for switch
switch (expr) {
case a:
something();
break;
default:
break;
}
like that
unfortunately we don't have that option π
i kind of forgot how i wrote switch cases in C not gonna lie
although this is not a chit chatting server
i am stressed and i want to chit chat among intellectual beings
hi
you can go to #ot0-psvmβs-eternal-disapproval
what you use match case for? can you share an example? just out of curiosity...
I do think the indented nature of Python prevents us from better syntax in certain cases
like full-powered lambdas, or match-case as expression like Rust has
has anyone studied TAFL it is such a useless subject my brain is nt braining
also just because we know programming doesn't make us intellectual :)
yes it does
Matching of tokens (produced by lexer.lex()) in parse() func
automata theory? it was one of my favorite subjects. and far from useless.
i mean better than some lolicon servers
π€ mind sharing some code
what
i'm not a match case expert, since i dont use it often
studying it 2 days before exam is tiring
What uses have you found for it?
i was editing it so it had some stuff that shouldn't be there to show you so i deleted unnecessary fluff and now presenting you clean one:
def parse(tokens: Iterable[ArgumentToken], command: Command) -> CommandNode:
node = CommandNode(command)
token_stream = TokenStream(tokens)
context = ParseContext(
node=node,
token_stream=token_stream,
)
while (token := token_stream.peek()) is not None:
match token:
case OptionToken(prefix=prefix):
token_stream.consume()
match prefix:
case OptionPrefix.LONG:
_handle_long_option(token, context)
case OptionPrefix.SHORT:
_handle_short_option(token, context)
case _:
assert_never(prefix)
case ShortOptionGroupToken():
_handle_short_option_group(token, context)
case ArgumentToken():
parse_mode = context.node.command.parse_mode
match parse_mode:
case ParseMode.COMMAND:
token_stream.consume()
_handle_command(token, context)
case ParseMode.OPERAND:
_handle_operand(token, context)
case _:
assert_never(parse_mode)
case ArgumentToken():
raise AssertionError(f"did not expect an {type(token).__name__!r} token")
case _:
assert_never(token)
_validate_command_node(node)
return node
mostly conceptual. for one, I feel like it made me understand and be able to construct regexes better.
but even beyond text processing, also a lot of things just are state machines.
it is just maths and langauge
i wanted this in python lol
i talked about it in here some time ago
every single thing i think about rust already has lol
what are they
from which bg u r
I am using case ArgumentToken hack to not to have a method() or Type alias
wdym
Idk if that's really appropriate
i mean ur specilization
I agree on both counts. Though I don't think university courses about this do a good job conveying that
systems programming, I would say
If there are mistakes, ignore it, I am still editing
which branch is that π
no course does that imo π
systems programming deals with the operating system itself. this is at various levels, from drivers to core OS processes and tools like init systems and daemons and so on.
interesting...
i mean okay
this means u were from cse background only ?
yeah, CS major in university.
Its stupid tbh. I feel like i am abusing match case lol
what I said above. #python-discussion message
which makes it interesting lol
it is just an extra subject like it is for ece students π
And has that case ArgumentToken(): so that i don't have to write put a type alias or an abstract method for subclasses
Is my approach appropriate? I do use raise AssertionError for assumption
i think i have read somewhere about .kind = EnumMember
Maybe that's more easy for statically typing
That looks... interesting
π«
I think it's a fundamental part of CS
oh, i didn't notice it, that case would never get triggered
you have case ArgumentToken(): twice, only the first one could get triggered
sorry, what is tafl?
Oh wait it has two case ArgumentToken() lol
Well its wrong, because i am still editing
i liked this:
case OptionToken(prefix=prefix)
its pretty clever
It catches prefix argument iirc
Or prefix attr
Theory of Automata and Formal Languages
And assigns to name at right side
instead of doing prefix = token.prefix afterwards
ClassName(attrname=varname)
you say it needs to be an OptionToken with a prefix attribute, and you store that attribute in prefix
CS is often much more about the theoretical mathematics of computation than about real-world software engineering concerns.
Yeah
case OptionToken():
prefix = token.prefix
is the same as:
case OptionToken(prefix=prefix):
thats a nice trick
guess so
In Python, we cannot statically know all subclasses of a class but at runtime we can (as far as those subclasses were found and evaluated)?
i mean, unless there's OptionToken without a prefix attribute, then its not the same
OptionToken does have a prefix, that is why we have another match case for it
say you had ones with and ones without, only those with would get matched
but in:
case OptionToken():
prefix = token.prefix
all would get matched
thats a small technicality though
actually
prefix = token.prefix would error
imagine OptionToken() but one doesn't have a prefix and goes down and ends up in assert_never lol
lol
lambda shared in here a code with many match cases and i found it interesting...
Share me that too :D
let me see if i can find it, i barely understood anything though not gonna lie
Tho i wished i had more stuff to add more cases, this one is barely 3 cases
unfortunately the link is dead: (https://paste.pythondiscord.com/XJQA)
#python-discussion message
oh :_(
you definitely won't find interesting match case usages in my codes though, since i really barely use match case haha... mainly because of the double indentation
I think i will change this into Token.kind where kind is closed end enum and use that in cases instead of token classes

is there any reason we're not resampling audio by doing a FFT and zero-padding/trimming the frequency array, then performing reverse FFT?
umm, you can i guess
although if you use match case for constants you kind of not fully utilizing its power for pattern matching
Would it narrow down token subclass too with that?
gotta try to implement this
it was just matching on pairs to implement like a 2d decision table
i dont remember what it was not gonna lie

but if you want, you can share a link for it, it was an interesting read
basically the usage of match case you did there...
oh and i did a | with a symmetric pattern to make the order not matter
(the link is dead)
yeah ik
not sure what you mean by that
def unify(lhs, rhs):
match (lhs, rhs):
case (Variable(name), expr) | (expr, Variable(name)):
return {name: expr}
...
something like this
idk if its actually good lol
its kinda ass
could be nice if you could store patterns in variables
FIRST. CLASS. PATTERNS.
pattern calculus
huh discord is changing the markdown colors
there is a problem with how to use that when patterns capture variables though
its not exactly obvious
how would a function that matches against an arbitrary pattern know what are the variables it gets from the pattern?
when the pattern is being used in a case it will know
the actions will get executed there
def func(scrutinee, pattern):
match scrutinee:
case ~pattern:
... # what variables do i have here? could it have accidentally reassigned to something?
def unify(lhs, rhs):
match (lhs, rhs):
case (Variable(name), expr) | (expr, Variable(name)):
return {name: expr}
...
to
pattern x = (Variable(name), expr) | (expr, Variable(name))
def unify(lhs, rhs):
match (lhs, rhs):
case x:
return {name: expr}
...
with just pattern aliases that works fine, sure
but not when a given name refers to an arbitrary pattern
Explicit is better than implicit.
what were you asking about then sweetheart
what you mean
Yeah correct term
first class patterns would be analogous to first class functions
like being able to pass a function to map or filter, you would pass a pattern to some function, or store it in a collection
i still dont understand what you mean
yes exactly, it'd be set as the argument name
thats the thing
^?
with a naive implementation, it just basically doesnt work
a pattern is just a predicate that may assign to the local vars on success
pattern x = (Variable(name), expr) | (expr, Variable(name))
def unify(patt, lhs, rhs):
match (lhs, rhs):
case patt:
return {name: expr}
...
unify(x, lhs, rhs)
and how do you know that patt binds name and expr?
thats what the function wants
that doesnt play out nice with how scope resolution works in python
it also means patterns have to match in names and that doesnt compose well
basically unhygienic macros
We donβt have the same aesthetic at all. Just two black and white pics weirdo.
- @neat locust
no need to be rude about it, it's just profile pictures
the "usual" solution (this is not even a topic that is talked about much in PL) would be to make them actually analogous to functions, have them return values
but then you wouldn't be able to do case patt:
yes, because it doesnt even make sense to do so.
def x(val, locals):
try:
a, b = val
except Exception:
return False
if isinstance(a, Variable):
locals["name"] = a.name
locals["expr"] = b
return True
if isinstance(b, Variable):
locals["name"] = b.name
locals["expr"] = a
return True
return False
you can already do "first class patterns" in a really stupid way with stuff like that yeah
ghost ping?
they deleted the message
the person who you pinged said something "i dont know you, dont mention me"
such a weirdo idk
(i have msglogger on)
(get banned you hecker)
9
fun fact:
try: a, b = val; except: return False
has different behaviour from
ab = list(val)
if len(ab) != 2: return False
a, b = ab
i mean thats obvious, the second doesnt check that it can list the val
sipi
?
thats like that tuple example that gets mentioned in here from time to time isn't it
wdym?
in the first one, the except will catch the case where val isnt iterable
that the error raises after a partial assignment
i haven't tried your code, just assuming
even if val is iterable
the second one has different behaviour even if you wrap it in try/except return false
i assume that a could have a value even if it errors
if its 1 element size in val
its the same sht as that tuple example, mentioned in here from time to time
I don't think so
at least not if it throws an error
UNPACK_SEQUENCE fully happens before the assignments are started to execute
what I was specifically referring to was that in case 1, there are never more than 3 items generated before erroring
in the second case, if the iterator never halts... fun
if its an infinite iterator it would get stuck in the first one as well i think
nope
thats the difference owo is referring to, it knows to only next(it) n (2 in this case) times and ensure that after that next(it) raises StopIteraiton
it doesnt need to fully list() it
in the first case, the error happens immediately after the third yield
interesting
I wonder whether the expression of the yield is evaluated... should be if you think about bytecode
so it errors as well but at the third yield, interesting to know
I feel like I'm missing context, but if you'r etrying to unpack a generator-yields-more-than-2 items into a,b, surely the expression to be yielded the third time must be evaluated because until then you don't even know if the yield will happen inside the generator - it might eg raise.
I was thinking about yield f(x) whether f(x) is evaluated, and I didn't test yet, but I'd heavily assume so
It must be.
what you mean cameron
in python's evaluation model it has to be evaluated
its not haskell
if its an iterator in order to know if its size is 2 u need to yield 3 times at least
Suppose f(x) raises some exception. Then the yield won't happen.
guys im going to learn phyton , what advice would you give me?
btw, i just published this blog post which touches on this, thanks for the question: https://nedbatchelder.com/blog/202604/school_is_artificial
don't compare yourself to others
now also mention why the 'we will always have access to $X in the real world' is a bad argument in school
def x():
cnt = 0
while True:
yield cnt
print(f"yielded {cnt}")
cnt += 1
try:
a, b = x()
except:
...
yielded 0
yielded 1
doesn't get to print yielded 2
what employers wants from me to know? wich skill is more valuable nowdays and can ai change programer?
so at yielded 2 it errors
now I have more to add to the blog post....
'can ai change programer' meaning what?
like solve problam
AI is changing the job of programming
while model providers do not yet charge the cost they would need to break even
Nevermind. I end up using an union like this (for now):
type LexerToken = OptionToken | ShortOptionGroupToken | ArgumentToken
now for match token:, token is typed as LexerToken.
Previously, it was just generic Token
i see
Also i decided on terms for my cliargparse.
class Tokenizer.tokenize(source: str) -> lexemes: list[str]
lexer.lex(lexemes) -> Generator[Token]
class Token.lexeme: str
previously i was using "argument(s)" as a term vaguely everywhere
you mean documentation?
a, b = iterable
# ~
_N = 2
if isinstance(iterable, (list, tuple, dict)):
_size = len(iterable)
if _size > _N:
raise ValueError(f"too many values to unpack (expected {_N}, got {_size})")
try:
_iterator = iter(iterable)
except TypeError:
raise TypeError(f"cannot unpack non-iterable {type(iterable).__name__} object")
_values = []
for _ in range(_N):
try:
_values.append(next(_iterator))
except StopIteration:
raise ValueError(f"not enough values to unpack (expected {_N}, got {len(_values)})")
try:
next(_iterator)
except StopIteration:
pass
else:
raise ValueError(f"too many values to unpack (expected {_N})")
assert len(_values) == _N
a = _values[0]
b = _values[1]
in params and field names
oh
a challenge for you
unpack a,b from infinite iterator
that does it, it only nexts 2+1 times
ie: 0,1,2,3,4,5..... unpacked: 0,1
using the syntax of a,b=x
i dont know if its possible
def take_first_two(iterable):
iterator = iter(iterable)
yield next(iterator)
yield next(iterator)
a, b = take_first_two(x)
(islice or whatever)
it must bbe an infinite iterator, but you can have helpers
def first(n, it):
it = iter(it)
for _ in range(n):
yield next(it)
a, b = first(2, x)
first(2,x) isn't infinite
then its impossible, the unpacking mechanism itself will error if the rhs is longer than 2, no matter what you do to the iterable
i dont know if its impossible, maybe though
Why make life hard? 
what if you try except the yield in a function?
This tests that the yield happened and control came becak to the generator. That second part oesn't necessarily happen.
I think the yield happened (you could yield from a function which prints to check) and that Python's mechanics then blow the a,b assignment, which will raise GeneratorStop (?) inside the generator, terminating it.
GeneratorExit you mean?
apparently it unironically does check for list, tuple, dict specifically for the error where it mentions the amount of elements it "got"
not arbitrary len. weird.
So put:
try:
yield x
except:
print("generator raised from yield", sys.exc_info())
return
the probblem is that the error happens outside
if you could somehow knokw what is trying to get unpacked, whats the expected size, if there's a determined size
not sure i understand what you're saying
from what i understood, the third yield raised an error outside
it did try to yield the third item, but errored
You were asserting that the lack of the third print meant the yield didn't occur. But yield is a 2 step process - the value goes out to whoever is calling next() and a value or exception comes back when the generator resumes, at the next next() or throw or send.
Let me make a demo.
the error happens in both places
i agree that 2 yields happened successfully, and the third errored
there was an attempt to yield the 3rd item
which lead to the error outside
the attempt was successful, it did yield 2
i dont know how the internals of it work, but could be
!e See for instance: ```py
import itertools
counter = itertools.count()
print(next(counter))
try:
a, b = counter
except Exception:
pass
print(next(counter))
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | 0
002 | 4
[~/tmp/disco/mtnjustme]fleet2*1> py3 yield3.py
+ exec python3 yield3.py
about to a,b=gen()
gen: start
gen: about to yield 0
gen: after yield, about to bump n
gen: about to yield 1
gen: after yield, about to bump n
gen: about to yield 2
gen: yield raised exception (<class 'GeneratorExit'>, GeneratorExit(), <traceback object at 0x1091229c0>)
Traceback (most recent call last):
File "/Users/cameron/tmp/disco/mtnjustme/yield3.py", line 19, in <module>
a,b=gen()
^^^
ValueError: too many values to unpack (expected 2)
[~/tmp/disco/mtnjustme]fleet2*1>
the a, b = counter line consumes 1, 2, and 3 from the counter
This is from this code:
import sys
def gen():
print("gen: start")
n = 0
while True:
print("gen: about to yield", n)
try:
yield n
except:
print("gen: yield raised exception", sys.exc_info())
return
print("gen: after yield, about to bump n")
n += 1
print("about to a,b=gen()")
a,b=gen()
i see
the only way that unpacking could know that the iterator wasn't exhausted is by asking for a 3rd value and seeing whether or not it gets a StopIteration. And once it has asked for that 3rd value, there's no way to put it back - it's already been yielded
that was the initial point
The purpose of my example, vs GG's, is to show control returning to the generator.
that is expected though
that except getting triggered is weird though
why did yield errored inside?
it yielded successfully
No, it's expected. That's what I was demoing. Control returns to the generator to tell it to stop.
but you can see the different, sii?
oh
yes π€¨
πββοΈ
thing is, i wonder if there's a way to know how many variables are trying to get packed
if you know that, you know exactly how many values to yield
gen() was a temporary. When that temporary is destroyed, GeneratorExit gets raised
of course it's not always known, but it's sometimes known
consider [first, *rest, last] = gen()
a,b u know that there are 2 arguments to get packed
Finally got Discord's light theme to kinda work for me β¨
This kind of flow, btw, is how async works: a coroutine which awaits yields, so that the event loop can run. The coroutine is resumed by the event loop by by passing a value (the await result) or exception back to the coroutine from the event loop.
These mechanics are hidden by the async/await keyword mechanism.
But async is cooperating generators.
yea not always, but sometimes
interesting
... because yield is an expression π
so you can know from inside the generator if an exception happened outside
that's not really what's happening here, though. Nothing is passing an exception in other than the interpreter itself, which is doing it because the generator has been gc'd
Not directly. But you get a GeneratorExit exception in the generator, which is how it gets cancelled.
Yes
yea, and you can do some cleanup if you want to as well
Or like a main thread has to have either a semaphore or a mutex in order to interact with the async thread. Once incremented or decremented (usually decremented), then the main thread can continue.
- create mutex
- Start async thread with mutex pointer
- wait for the mutex to update
- async thread runs
- async thread updates mutex
- async thread exits, and the main thread continues as condition check is now passed
(Sorry, I've been writing a lot of concurrent Swift lately)
if the call to gen is at the line of the unpack you can just
import sys
import linecache
def gen():
frame = sys._getframe(1)
context = linecache.getline(frame.f_code.co_filename, frame.f_lineno)
target_vars = context.partition("=")[0].split(",")
amount = len(target_vars)
return range(amount)
a, b = gen()
print(a, b)
kind of fair
something a bit more sophisticated would be checking the bytecode argument of the previous nearest unpack_ bytecode instruction from the frame's lasti
notice that the error tells you the amount btw
trying to unpack 3 to 2 iirc (so that information is stored somewhere)
only for list, tuple, dict, it uses their len()
That side isn't direct. But you can pass in an exception: https://docs.python.org/3/reference/expressions.html#generator.throw
Just above that is generator.send(value) which is how the value of the yield expression is received.
I just wanna say
God bless platformdirs
but still the amount of what needed to be packed iirc
too many values to unpack (expected 2)
so expected 2 that information is stored somewhere
if you could get that information beforehand, you could islice the iterable and return it
Yes, but you don't know the generator made too many values without triggering the final yield. And python raises the too many values exception.
i dont use send/throw at all, still interesting that it can happen without even send/throw
pathspec, platformdirs, and uhh what was the other one for that?
its the bytecode argument to UNPACK_SEQUENCE
on an error that occurs outside, sending GeneratorExit
As GG mentioned, that exception occurs when garbage collecting the now discarded generator.
You could hold onto the generator though and defer the gc.
that makes sense i guess
i shall do this
actually i recently had an idea about making a language that would compile directly to cpython bytecode
and i wanted to play around with compiling to match expressions
i see
like, use the bytecode instructions that cpython uses for match, but make the arms produce a new value on the stack rather than just do control flow for statements
whats the benefit in that
"native" (to the python interpreter) implementation of a match expression (which my language would have because based functional programming everything is an expression)
i also want to learn how to implement lazy evaluation in languages
given that Python's bytecode format isn't stable, it'd probably be a better idea to transpile to Python and then compile the Python to bytecode instead of compiling directly to bytecode. Way less maintenance
Thanks a lot for the help with improving my code. Your guidance made it easier to understand what I was doing wrong. I was able to fix my errors and clean things up properly. I appreciate you taking the time to help me make my code better.
that way you can only get bytecode that is a result of compiling well-formed python programs, which match-expressions arent
in python match arms are blocks of statements
What's not "stable" about the bytecode? that it changes version to version, or that it is machine/os dependent?
changes version to version. its not os dependent, that would defeat the purpose of bytecode, the purpose is to abstract from this detail and run anywhere
Ah
both, I believe
Oh
not OS, but I do think it's architecture dependent?
so technically, it's possible to do this in cpython
like, endianness dependent? i think the marshal format makes sure to handle that
endianness, integer size, etc
this correct right^
pretty sure marshal is little-endian throughout
i would just need to change the code in the parts that match jumps to. its just that normally its code that doesnt have a stack effect because its compiled from a block of statements, but the match instructions themselves are just control flow
perhaps I'm wrong then. Someone recently mentioned to me that the bytecode format is arch dependent in recent versions, but perhaps I misunderstood them
i see
why specifically you want to go with python bytecode if you want functional
wouldn't it make sense to use something rust uses for example
https://docs.python.org/3/library/marshal.html
The format is specific to Python, but independent of machine architecture issues
or even haskell
its not a practical choice, just a funny one
the benefits are python interop
and learning about python bytecode
If I have aliases for something, say types (Where Nat is also natural) should I loop through every type to check if that's a type's alias or have a reverse lookup dict?
what do you mean by reverse lookup
Nat -> natural is not a reverse lookup, its a direct one
we need more context
Nat is the actual type natural is its alias.
The reverse dict would have this basically
{'natural': 'Nat'}
i dont understand why are you calling this "reverse"
Because the "actual" lookup would be from Nat to natural, checking if natural is one of its aliases?
Instead the lookup is reversed, getting the actual type directly from the alias
why would you do that
Nat -> natural is normal
natural -> Nat is reverse
When I say that natural is the alias of Nat and then I say
let b : natural = 6
I need the validator to somehow understand that "natural" means "Nat"
it does not make sense to have a {Nat: natural} mapping if natural resolves to Nat. you'd have {natural: Nat}, and this would be ~let b : Nat = 6 after resolving aliases
if your type aliases are simple then typealias A = B should just be type_table["A"] = evaluate_type_expression("B")
and if you have parametrized aliases you handle them similarly to functions
because well really they are, type aliases are just variables for types, and parametrized type aliases are (restricted) functions on types
problems only appear with recursive type aliases
is this going to be a long discussion about a language other than Python?
this is just a general language implementation discussion. python has type A = B
does python have/had a function/builtin that has a name A that does everything but A
what does that mean?
a name that doesnt at all describe what the function does?
yea,language barrier is working on me rn
no, what you said makes sense, its just that A has to be treated as a variable representing some identifier
"everything but A" doesn't make any sense, no matter what you replace A with.
would "anything but A" avoid that problem? since its kinda referring to 1 thing, not "every"
since "everything but A" is a figure of speech i dont treat the "everything" in it literally, i just infer from context, so i didnt mind it
"everything but A" is a figure of speech, "does everything but A" doesnt make sense if we interpret the "everything" literally since a given program cant do "everything", it does something specific
βBut doesnβt do Aβ would be more appropriate
How would !x work if x is a ternary data type rather than a boolean?
you can get the instruction for it, and then get its value (from the calling frame)
i think the most obvious one is the output table being a reverse of the sequence of states
thats what i said in the previous message, yes #python-discussion message
~x?
interesting, so its possible i gesss
0 1 2
# ->
2 1 0
?
Perhaps
1 2 0?
What if it's -1, 0, 1 though?
1, 0, -1
unfortunately in this case !0 = 0
if you dont want that, then cycle the states (in either direction) rather than reversing the entire sequence
What's the word for these 2 types of ternary I forgotr
There's the one where it's balanced with -1, 0, and 1. then the other one which is 0, 1, and 2
(un)balanced
yeah thy
0 1 2
# ~
1 2 0
2 0 1
in this case (!x) != (x)
Does anyone else ever wish that
my_list = [1, 2, 3]
print(my_list[4])
would print 2?
implicit wraparound? no, i dont wish that, it would be a common source of bugs
!e ```py
a = [1, 2, 3]
print(a[-5])
:x: Your 3.14 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File [35m"/home/main.py"[0m, line [35m2[0m, in [35m<module>[0m
003 | print([31ma[0m[1;31m[-5][0m)
004 | [31m~[0m[1;31m^^^^[0m
005 | [1;35mIndexError[0m: [35mlist index out of range[0m
i can always just do seq[idx%len(seq)] if i want wraparound in some specific place
or do seq = Circular(seq) if its going to be circularly indexed in a lot of places
is Circular in stdlib? or you create it on you own?
i dont think there is one in stdlib. i've written my own a couple of times, you basically just do this % thing in all the methods related to indexing
good idea. just overwrite __index__, right?
isn't itertools.cycle it? https://docs.python.org/3/library/itertools.html#itertools.cycle
a[b] is __getitem__
__getitem__
for iterating yes, not for a sequence, like one that you'd index into
sorry, too much rust and python lately
i see, make a new indexable thing that hides the modulo
Are functions without recursion just text replacement basically?
yeah thats what Circular would be in this case
Without the fact that variables are scoped
see "inlining"
I will, thx
they aren't text replacement because of scoping, and because of stack traces, etc.
ummmm, not really. because you can pass functions as arguments that can be used for in other functions
Python doesn't inline, but C does during compilation.
and inlining still isn't text replacement, because of scoping, etc.
mhh i see
an indepth explanation of inlining would explain the differences from textual replacement,
when its applicable and when not
its an interesting topic
Ned I need an opinion
I'm bikeshedding Claude's suggestion instead of just moving on
if your functions have a return statement then textual substitution already fails, you need to do something a bit more complicated
Claude gave me these cache keys
def _licensing_key(design_code: str) -> str:
return f"{KERP_NAMESPACE}:art:licensing:" + json.dumps([design_code])
def _print_records_key(design_code: str, ground_color: str, gender: str) -> str:
return f"{KERP_NAMESPACE}:art:print_records:" + json.dumps(
[design_code, ground_color, gender],
)
I don't like the lists, I don't really wanna be using JSON here at all
I feel like the first should just be raw and the second should just use something simpler like commas
oh god why
why json.dumps? Why not just concatenate the strings? You already have colons as separators.
If you're sure the design_code etc have no commas or colons that should work. The JSON just arranges an escaping mechanism. Unless I misunderstand.
hash(json.dumps(code))
not literalyl hash()
put a sha512 in there or something
This is why I hate ai btw
complexity without explanation?
yes!
or if you are concerned about needing to quote the contents of the strings, why not: json.dumps([KERP_NAMESPACE, "art", "print_records", design_code, etc])
Design code is guaranteed to be alphanumeric
The others two could have a limited set of special characters, namely ,/
It's only just now hitting me that training these models on so much publicly available code will yield those kinds of results, because genuinely good code is hard to find
ai should read clean code or smth
def cache_key_for(keyspace: str, **key_args) -> str:
return f"{KERP_NAMESPACE}:{keyspace}:" + hashlib.sha256(json.dumps(dict(sorted(key_args.items()))).hexdigest()
woah
i think if you ask claude why it wrote it this way, it will tell you.
I did, it did
Code that's worded like it's good but is actually trash
and?
If you've got a char guarrenteed not to be in there (eg :) you could just join with that.
if he didn't like json.dumps, how does adding hashlib help?
actually, I don't even think any "explanation" you'd get from Claude would be a record of any actual process of reasoning on its part, but a post-hoc rationalization
Good catch β there's no functional reason for the list around a single value. I used
json.dumps([design_code])for both keys to keep one consistent encoding shape (so both helpers look symmetric and you never have to think about whether a key has one or many components), but for the licensing key that just produces noise like["DESIGN1"]instead of"DESIGN1".A few alternatives, in increasing tidiness:
- Drop the list for licensing and just use
json.dumps(design_code)β key becomeskerp:art:licensing:"DESIGN1". Quotes still come along because JSON, but it's at least scalar.- Skip JSON entirely for the single-value case β
f"kerp:art:licensing:{design_code}". Simplest, readable, but you do need to trust the input doesn't contain:or other separators (design codes here look safe).- Keep
json.dumps([...])for both. The only real argument for it is "every key value is a JSON array of its parameters," which is mildly nice for debuggability of multi-arg keys (print_records), but it adds zero value for licensing.If you want, I can change the licensing key to option 1 or 2. Note this would invalidate any already-cached
kerp:art:licensing:[...]rows on existing machines, so users would see a one-time miss after the change (auntw cache clear --namespace kerp --yeswould also do it cleanly).Continued with Autopilot: Task not yet complete
Answered the user's question about why the licensing cache key wraps the single design code in a JSON list, explained it's just for symmetry with the multi-argprint_recordskey, and offered three cleanup options.
That's going to make the key hash dependent on the ordering of the keys
Oh, right
Which isn't a problem in my case
But still overcomplicated
what did you think of the options it offered?
fixed.
What are the requirements for the cache keys? What do the strings look like?
it's fine to have a better idea and implement it.
There are a dozen problems with these cache keys:
- you're packing in complex formats
- they're big
- they're unbounded
- your generate function is insufficiently modular
- your generate function can't take in any parameters besides a str (???)
what does insufficiently modular mean, and why does it need to take other types than str?
this example has a licensing key and then a print records key and they are effectively the same code just with a different number of parameters
There's no reason you can't just *args that instead of having several functions
that could also work
but they are readable in case that matters
do you ever go looking at your cache
no
readable cache keys can be very nice.
I typically purge it before doing that
What are these keys pointing to?
It doesn't, the computer is handling all caching
But there's no reason to go create some bespoke format instead of a 20 character strings
If you want readable keys you can just ":".join()
SQLite table that's just key,value,expiration
Value is JSON
You have a single SQLite table for literally all your data?
I'm with Bast: just join with colons and let sqlite do the index.
it's a cache
For a CLI tool
def cache_key(*keycodes: str):
return KERP_NAMESPACE + ":" + ":".join(str(i) for i in keycodes)
def licensing_key(design_code: str):
return cache_key("art", "licensing", design_code)
hey is anyone here a reverse engineer
Sure, why not
cache for what though? what are the values?
API responses
and your inputs are the parameters to the API call?
def cache_key(*keycodes: str):
return ":".join([KERP_NAMESPACE, *keycodes])
print_record_response_cache:
design_code,ground_color,gender,response
``` then make an index on `design_code,ground_color,gender`
if there were what would you ask?
Yeah, that is better, thanks
you're trying to cache it so that if you call the same inputs for the API you get a cached response?
I'm working on a project which does such a cache also. It's one table. (Well, no, 2 tables: entities and tags for them.)
My cdrip script uses this for the musicbrainzng cached responses for example.
i need to hire someone for a project thats why
I'd be worried about the codes containing :. You never know what's coming. Maybe you could percent-encode them or something
go put up a post on linked or something
LinkedIn not Fiver?
no reverse engineer worth their salt is on fiverr
!rule 9 not on this server
why stop at just one?
fair
yeah.. you won't find anyone here to do that lol
why nott
#python-discussion message you need to reverse engineer this message
what
πΏ
I hate ai code
imagine someone bruteforcing random paste.pythondiscord.com links
to find cases like this
I think the implementation of recreating the KERP client was done very tediously here
But its pretty dead simple
No vast architectural hell
absolute cinema
lmao
Weird. Who would write that?
IDK, kinda wanna meet them and see what they're like one day
I assume they're like a seven.
I'm impressed at you even remembering that repo. I'd forgotten about it.
I'm not sure
I've never done this before -- hence me asking Claude to show me an implementation
My brain wants option 1, no need for a list if there's only one value
But I can get behind the consistency of just always using a list to keep everything uniform
I think about it every time I have to re-paste because I missed a redaction
-# which is every time I paste π¬
this is where your taste comes into play. as you can see from the discussion here, different people will do it differently.
Yeah my code often sparks... very heated discussions π³
did you write this? or Claude?
The code or the reply?
code
no
would be funny if you wrote the code by hand but than offloaded the discording to claude
new project idea unlocked
I asked Claude for an example implementation because I have never done SQLite caches before
I started doing some copy-editing and got stuck bikeshedding
How many entries are going to be in the table at most?
~25k
And how many kilobytes/megabytes of values per entry?
actually, maybe this doesn't matter
If you wanna see how dangerous it is when I'm left to do these things myself:
pos = _parse_pos_csv()
for po_number, items in pos:
if Path(f"pos/{po_number}-request.xml").exists():
print(f"Skipping PO {po_number} because request XML already exists.") # noqa: T201
continue
pre_po = build_purchase_order(po_number, items)
po = build_purchase_order_request(client, pre_po)
client.service.sendPO(SanMar.promostandards_ws_version, SanMar.username, SanMar.password, po)
Path(f"pos/{po_number}-request.xml").write_text(client.last_sent().str())
Path(f"pos/{po_number}-response.xml").write_text(client.last_received().str())
print(f"Processed PO {po_number}") # noqa: T201
sleep(2) # Sleep to avoid overwhelming the server
Why do you want to have the namespace as part of the key and not separate column? That sounds like a holdover from Redis or something like that
See how many things would be simplified if there was a namespace column
def count(self, namespace: str | None = None) -> int:
"""Return the number of stored entries, optionally filtered by namespace."""
with self._connect() as connection:
if namespace is None:
row = connection.execute("SELECT COUNT(*) FROM cache_entries;").fetchone()
else:
like = namespace + NAMESPACE_SEPARATOR + "%"
row = connection.execute(
"SELECT COUNT(*) FROM cache_entries WHERE key LIKE ?;",
(like,),
).fetchone()
return int(row[0]) if row else 0
``` I'm certain that this method is O(N) where N is the number of all entries. I wouldn't expect a full table scan to count how many entries there are in a namespace
I thought thats what indexes were for
It already has all the keys sorted so it can jump to right where it needs to
But IDK databases very well
O(N) is worst case but if cache entries is indexed its faster im pretty sure
Did you add an index?
not yet
you should
Index make faster
i honestly don't know any good resources for this topic, i've been looking for some myself
caching or indexing?
how would you cache a database
database design and interacting with relational databases
caching a database is rather funny.
I think they meant caching api responses or repeated (external) db calls, to a small db.
yep
API responses are getting inserted into cache.sqlite
I actually wanna change that
Claude put .db but I prefer being more expli.....
Oh Claude was smart
CACHE_DB_FILENAME = "cache.sqlite3"
we using AI now 
IDK why .db is such a big thing
I also don't know why I care
Yeah, getting example implementations for things that're new to me and pushing all the new shiny buttons in VSC along the way
I just clicked this button and it turned red and now VSC is doing something completely different than it was five minutes ago
This server's members shames AI while at the same time also uses AI
Hypocrisy! xD (i am just kidding)
Everyone having their own opinions isn't hypocritical
Just ironic to me sometimes
AI is controversial
there are different people in this server, we are not a hivemind
yet
"we are not a hivemind... we are not a hivemind..."
"we are not a hivemind"
True
making the same joke proves we actually are
after reading this "bikeshedding" debate; and with consideration of AI (Claude Code)-
I think that you should plan your approach a bit more.
think how you would want to interact with the code, and get more familiar with the abilities of SQL .
having a working demo would help.
don't let AI decide regarding structure and (key) design aspects.
before you know it, you'd be chained to a workflow you don't like; and forced to work with functions with half assed behaviors.
tldr; learn your stuff, and decide for yourself.
only then, if you must, face AI to assist you.
personal project just need to work, and be fairly manageable. (not AI bs)
alternatively it proves that humor is deterministic
why is it funny?
I use AI as autocorrect for code.....
Does that mean i can write a parser for humour without ambiguity? Yay!
I use three AIs to debate upon which term/word is recommended and more faithful to its task.
why cache a (local) database, if you already have said database.
unless some repeated heavy queries are made, local db calls are rather fast.
PG has built in caching
Not sure if SQLite does too
fast, but not as fast as memory
is it a good practice to use literal unpacking?
like instead of doing range(1, 10) several times or py min = 1 max = 10 range(min, max) ...
doing py x = (1, 10) range(*x)
Well thats what I'm doing
I got one implementation, went "I didn't like that very much", and now I'm here getting different ideas
overshadowing built-in min & max ? 
π₯
its best to have it criticize your code; auto correcting from the getgo usually breaks design intentions.
plan it (maybe with AI), only then implement it. otherwise it likes to hallucinate decisions and limitations.
you could save the range to a variable
The first example is what I would use. It is more explicit as to what the numbers mean.
some_range = range(1, 10)
"Explicit is better than implicit" Better to not use the unpacking.
oh hi dan
ok thx
thoughts on this?
Noice
I've been using LLMs instead of Google for long time now.....
oh no
That would work if you need to do it a lot.
Could functools.partial help here?
With what?
range_generator = partial(range, 1, 10)
ranges are immutable
Just do my_range = range(1, 10) no need for a partial since you get a Range object.
hmm
imo that's the best approach; it can research things faster. 
some even made multiple agents, to search, discuss, and only then showcase the best matching data for a search query.
Use clearly named variables for the min and max of the range. Use range where you need range. Make it readable without any guesses as to what is happening.
(why did you capitalize it?)
And, unlike Generators, you can reuse a Range
I didn't know that
yeah range is a lazy sequence
I thought since it's a class it would be capitalized. I was wrong.
pendantically; range is a range. Not a list, tuple, sequence, collection, generator, or otherwise.
builtin class
It is a sequence and sequence is iterable.
!pep 8
Someone send this to the core team
they need it
lol
It functions similarly to a Generator though which is why people think it is.
the new builtin class is in lowercase btw, so no lesson learned
It's old. Probably predates PEP8
I agree. It also behaves like a sequence, though it is not a sequence.
Ranges implement all of the common sequence operations except concatenation and repetition (due to the fact that range objects can only represent sequences that follow a strict pattern and repetition and concatenation will usually violate that pattern).
no excuses
ohyeah
!pep 661
All the excuses.
are we sure?
>>> isinstance(range(1), Sequence)
True
it got accepted?????
Well, now I'm learning things. This is good.
Since when
One of the unsung changes from 2 --> 3 was changing how range works.
Yesterday or the day before.
So it's an instance of an abc that doesn't implement all of the abc. :|
mhm
I have been waiting for it since last year, finally!!
Another huge W for 3.15
Btw, the correct annotation for a contextlib.contextmanager function is Generator, not Iterator. Maybe you're not running a type checker on your code.
https://github.com/python/typeshed/blob/68517355a3269be407bde20fea8fd66af2dc4241/stdlib/contextlib.pyi#L93
At this point they're trying to preserve convention, the idea being that builtin or C classes are lowercase and user-defined classes are uppercase (this comes from Python 2 when these two were effectively distinct).
stdlib/contextlib.pyi line 93
"Annotating the return type as `β-> Iterator[Foo]`β with `β@contextmanager`β is deprecated. Use `β-> Generator[Foo]`β instead."```
see the "Resolution" part of the PEP, https://discuss.python.org/t/pep-661-sentinel-values/9126/337
Probably won't get into 3.15 though - too late in the process.
since someone announced it in #internals-and-peps around 2 days ago
Nooooo
its already implemented, just needs to be merged
https://github.com/python/cpython/pull/148831
Please!!!! Accept it for 3.15!
It is? Then it will be in 3.15
Yay
Uh... nope, nox -s lints runs both mypy and ty, and neither is flagging that line
Ah, I see. I'm just behind the times and didn't read far enough.
Changed in version 3.2: Implement the Sequence ABC. Support slicing and negative indices. Test int objects for membership in constant time instead of iterating through all items.
β οΈ
Yikes... none of them catch this. Pyright does: ```py
from typing import overload
from warnings import deprecated
@overload
@deprecated("stinky")
def stinky() -> None: ...
@overload
def stinky(x: int) -> None: ...
def stinky(x: int | None = None) -> None: ...
stinky()
``` mypy in fact never complains about calling deprecated functions at all
I think I remember reading something about that
That they explictly decided to ignore those
Run mypy in strict mode π it helps solve a lot of bugs that i never expected
Why not ty?
unfinished, has missing features and still has @Todos
It is vaugely annoying
I have to put
[tool.ty.rules]
# False positives that mypy sees
unused-type-ignore-comment = "ignore"
But I like seeing how the outputs compare
woah did discord's syntax highlighting change
I was just trying to see if ty supports something now, and the entire playground crashed and caught fire
it did
i like it
Does it actually work now?
no the colors
probably not but there's bold
Bold?
that's the TOML highlighting
bold
the whole isinstance thing can get squidgy
the colors changed, I thought that was what you were asking about
what's the difference between an abstract base class and abstract art
they're both pretty abstract
While true, I was operating under knowledge that is no longer true. So I do appreciate you calling it out.
One teaches you something.
i tried it not knowing what the answer would be
Do you have tips on finding modern stack buffer overflows not software patched but patched by hardware/OS/compiler security protection mechanisms in the latest technology? Itβs for bug bounty testing.
why does isinstance(True, int) return True
i presume you talk about abstract art
Because bool is a subclass of int.
Because bool is a subclass of int.
True is 1 and false is 0
everything's a really big int in my heart <3
thx
guys , does anyone has an excell thingy that might help me to find some command/ libraries for python ?
im a beginner
(True is 1 and False is 0 is false though, 1 is a distinct object from True)
Join a βundisclosed private online forumβ and get early access to Mythos
does valgrind do this?
A what?
You want a spreadsheet?
yeah
!learn
Here are the top free resources we recommend for people who are new to programming:
- Automate the Boring Stuff β an online book (also available to purchase as a physical book)
- Harvardβs CS50P course β video lectures (slides and notes provided) with exercises
- Python Programming MOOC 2026 course β text-based lessons with exercises
- Corey Schafer's YouTube playlist
For a full, curated list of educational resources we recommend, please see our resources page!
it should
Do you have an example of the type of spreadsheet you want?
well, only if a buffer overflow actually happens
#bot-commands
yeah , a library one
but like as i said , im new to python and programming overall xd
I don't understand the question
some of my friends just said that it would be useful to have one
1 sec
(labkit) @shenanigansd β /workspaces/labkit (main) $ uv run untw cache info
Path: /home/codespace/.local/share/LabKit/cache.sqlite3
Size: 20480 bytes
Entries: 0
(labkit) @shenanigansd β /workspaces/labkit (main) $ uv run untw cache path
/home/codespace/.local/share/LabKit/cache.sqlite3
Is there any reason to have a dedicated subcommand just to print the path?
Yes
Iβm actually fuzz testing using mutation fuzzing some of the latest technology right now but I havenβt found any vulnerabilities yet
Hello!
"latest technology" like what?
Latest Unix 64-bit based operating systems and Apache2/nginx
Teleportation 
oops , nvm , my bad , i just realized my dumb question xDD
hiiii
Hii
The comma π
/usr/bin/gnumeric-1.12.60 (part of Firefox) has encountered a fatal error and was closed.
yeah thats not firefox
π
Iβm going to post on Reddit
Do as you pleased
smh I can't reproduce the ty bug
only happens in the playground and under mysterious circumstances
I'll let their AI thing find the bug and fix it
Can make scripting to get a single value easier.
Yeah I just couldn't think of a reason I'd want a script to have just that one path unless I was deleting it
(labkit) @shenanigansd β /workspaces/labkit (main) $ untw kerp process-art-for-domestic-master "Domestic Master 04-24-26.xlsm"
Processing designs ββββΈββββββββββββββββββββββββββββββββββββ 9% 0:39:30
whyyy does 17k x2 HTTP requests take 2h
someone buy them faster server hardware π
oh kek thast says 39
As soon as I grabbed it it halved
I guess it head me
OH
Is the cache already making that big a difference?
lol
27% 0:15:54
that doesn't seem quite accurate
I will say
It is very convenient of this vendor to have absolutely no rate limiting
is it sequential
Currently, yes
yikes
What? Who does like 50k+ sequential HTTP requests??
parallelizable
IDK how I'd do that with this data though
I'm iterating over a spreadsheet one row at a time and combining data from different columns to make my search query
I could collect ahead of time
But at least ~10% is duplicates
So I'd need to filter out all the duplicate requests but still remember which set of rows need to updated for a given request
And at that point with all that mapping, I'm not sure that would be any better
does python-help do code reviews? Like more experienced people giving feedback about quality of code or is there another dedicated channel for it?
There's a code-review tag
π«‘
#1035199133436354600 is not an unreasonable place to ask for someone to look at your code.
do note that the larger your codebase is, the lower the probability that someone will have enough free time to review it
Fair
Man I hate progress bars
The upstream gets mad at me and slows down? "2 hours remaining!!"
I hit the 500 duplicates in a row? "only 5 minutes remaining!!"
Actually kind of staggering how fast you get responses in this server kudos for that
If you have something specific you want people to look at, ask there.
I will, thanks!
There are a LOT of us here
@pallid garden do !server
!server
And that's just your personalities π
π²
Oh damn
Anyone can do that?
the other programming servers have a ton of people too
but they are too busy dealing with the syntax /jk
I'll take notes for my own server, this looks clean af
The member count is MASSIVELY different
magnitudely different
it would most likely still be faster, since file reading is most likely also faster
Fair
It does take like a full minute just to load this file into memory
It's a 19 MB Excel file with values calcuated by macros
But once Python can get all the numbers it gets a lot quicker
bro should memmap
Godlyyyyy
I should actually memray it
Just to learn how to use memrary
This thing takes so long to run I'll have plenty of time to push buttons
is the combination expensive?
If so, a map/reduce style might be relevant
i honestly think doing this in a threadpool would net you some big performance improvements
This is hard to do well, Iβve tried. And failed.
There is also a point in which you would want to do work with data while fetching stuff
Not even a little
Its a pinch of splits()s and just a dash of concats()
we have 122 staff channels? I think the count is wrong... there might have been many channels in the past; yet they are now removed/locked these days.
then batching and parallelizing requests might be a better avenue
Joe's secret channel stash
there's that too
faster to fetch 20 rows at a time than a row at a time
right

Every staffer gets a channel:-) you get a channel and you get a channel andβ¦
Guys, today has been a weird day for me. I want to code and forget about stuff, what do you think is best? Continue breaking my mind around Tic Tac Toe on Pyside or go and play Codewars :b
Other suggestions are accepted too
Sadly, these channels were probably created in series.
third choice, work on a personal project rather than general issues.
I mean, I just want to distract myself for a little while
What if the staff all got BEEEES
Why not a staff forum?
I, for example, am working on a config interface and console manager with a local webpage.
-# you'd be surprised how much functionality exists in modern browsers nowadays...
play with perlin noise or learn about bspline
I'm actually curious what you guys would suggest
Deliverable
A production-ready bulk processing solution that:
- Accepts a structured input dataset (e.g., spreadsheet) containing design identifiers
- Processes the dataset against K-ERP systems of record
- Returns an updated copy of the dataset with relevant licensing and file status fields populated
The solution may be exposed via one or more interfaces (e.g., CLI, TUI, webapp), to be determined during implementation.
- https://github.com/[redacted]/roadmap/issues/173
They wanted a website but my non-technical boss didn't want to "give away [compute] for free".
I've got this CLI just for testing. And apparently we're going to give the client the CLI for the beta phase but they're not happy about being forced to do "that programmer stuff".
My org is too cheap to get me a code signing cert for me to sign some desktop app,
What're my options for user friendly UI?
bspline it is, idk what is that but sounds better than noise
It's how to compute curves in 2d/3d. Lots of fun and applications!
Oh shit its done
That sounds really cool, tell me more
(labkit) @shenanigansd β /workspaces/labkit (main) $ untw kerp process-art-for-domestic-master "Domestic Master 04-24-26.xlsm"
Processing designs ββββββββββββββββββββββββββββββββββββββββ 100% 0:31:46
Yeah that's a QUARTER of the runtime
Dog bless cache
A quarter? Wow, that's an insane optimization. Can you explain what it is in simple words and what the optimization was?
Let the CLI emit in html mode and turn it into a simple cgi script? Not entirely joking.
Caching HTTP responses to avoiding making duplicate lookups
cash
holy fuck
absolute dollar
There are.... 17,257 rows in the spreadsheet
(labkit) @shenanigansd β /workspaces/labkit (main) $ uv run untw cache info
Path: /home/codespace/.local/share/LabKit/cache.sqlite3
Size: 3604480 bytes
Entries: 9424
Namespaces:
kerp: 9424
Only 9k of them are unique??
HALF of my HTTP requests were useless?????
absolute duplicatoin
apparently
dollar sign means user
no wonder it made such a difference
I wonder why
more than half
your median request is useless
your mean request is in a superposition of usefulness and uselessness but its leaning useless
of course that presumes useful and useless are equally weighted
I apparently really misunderstood the shape of the data
I think I've heard of that language once and it was on r/cybersecurity in an exploit
i vaguely remember cgi but i als odont
cgi? cgi isnt a language
o
OH @ashen cipher its even worse
?
I've got a program to parse and manage some personal data. the core logic is already done.
issue is that although I've put flexibility into the code, along with config files and other knobs and switchesβ going through the configs and manually modifying parts everytime I want to change something is tedious. it also lacks "responsiveness"; like I will need to restart the program to reload the new config.
so I thought to make a GUI. from personal experience, the builtin modules are rather clunky, so I turned to craft a web application.
stuff is much easier now; even added custom config reload events and more.
even better, it now pushes the output to a visual showcase; calculated by the browser (using JS, WebGL, and other external js libs). lately, I also added remote functionality, to view and access the program from my phone while away.
working on your own projects (or side-projects) is fun and very productive.
there are many (more) things to add, customize and modify! 
I'm making two HTTP requests for each of my 17,257 rows
And I'm caching both of them
So that's actually 34,514/9,424
25k pointless requests?
I owe the upstream an apolgoy
...
Oohhh that's so nice. :D
My most interesting project is a discord bot, and making a single useful command takes me a whole afternoon of investigating and testing
I really need to get better at these things
Hey it takes me that long too
Discord bots are weird
Too weird :b
Also, I absolute hate slash commands. They take too much to sync.
To much time you mean?
You can set a dev guild that syncs instantly
@frosty oriole knows that stuff
look into other projects, example classes, and code snippets in the docs.
I found that copying, and modifying things to suit your specific needs teaches a lot, and saves a lot of effort.
I might have to try this, I usually follow the "If I can't make it, I shouldn't copy it".
globals sync immediately now too
Wait what
Since when?
It took like 2 minutes for a command that literally only sends "This is a slash command" to sync.

Maybe I did it wrong, idk
That's just Discord
TLDR Discord's caching issues and discord.py have been a long-fought argument between rapptz and Discord for reasons I don't even want to get involved with
You been practicing pyside?
Hiiii, YESSS, this morning I tried some stuff
I managed to replicate the player system
But I got stuck with checking wins and paused there
Nice! Getting the hang of layouts and signals?
Yeah :3
I now want to go on with detecting the wins, and something to add over the CLI version:
After a win, you get prompted to have a second round, and it'll need a win counter for each player.
lol. I usually follow, "If I can't make it, but need it- I should have it, then understand it".
-# note: this relates to real code; with some reasoning behind it.
-# often completed projects, preferably with a person to converse with, and understand their intentions & decisions.
-# AI code is rather peculiar, since it does not follow normal reasoning route; it does not have much considerations behind it- which often results in misleading and unreasonable coding practices.
That's not too bad. You could just add a play again button
Yesss
Also, to get the hang of it, I could also write wins to a file to save them even after the game closes
I'll see what we can do today, I at least want to make the win check
It used to be 24h
maybe using a plainTextEdit widget

I think I saw this one, is that the big line edit?
yeah, it's basically a multi-line line edit
good for text editors, but I often use them to log things
It also works to display logs, my friend's app uses that
Haha, we thought the same
bruh I thought this was a seal
I used it recently to view information about a widget. I use this for 3d software, it lets me create groupings of specific objects. I can right click and view what's in that group and it displays in a plainTextEdit
Whaaaat, that's soooo cool :0
this is easily one of my most used pyside tools that I've built
Can I make a thread today too?
sure I'll be around for a bit
Yay
Do beginners actually read python docs, like no external libs?
sounds insane considering none of it makes sense to me, seems like more of a reference manual
the python docs are mostly a reference manual, yes.
generally the docs work well for people familiar with programming already and are coming from a different language. As you build up your programming vocabulary, the docs will start to make more and more sense
what in particular are you looking for?
That's what I thought as well, all though discord.py's docs are actually quite simple
random module, had to resort to a tutorial because none of the docs made sense to me, new words etc.
Maybe I'm just tired, I'm going to sleep goodnight!
a tutorial is a good way to learn
I figured, kinda felt like it was cheating at first but It's just efficient to get a grip on new things
most docs should be simple if you have the underlying knowledge to understand them
there's a reason school isn't just handing you a textbook and saying "alright see you in 6 months"
textbooks arent reference though, they are large tutorials
maybe a closer comparison would be like a manual, or a dictionary
yeah maybe that wasn't such a good comparison then
That actually happened to me during the pandemic. Definitely one of the reasons I did not finish getting a degree
I was told by a friend I can share my python projects here is it true?
yikes, I weep for anyone who had to do any schooling during the pandemic
i weep
π«
Do you guys also help share the project on Reddit too if it's requested?
uhhhh.... no? I've never heard that before. Do you need help with Reddit?
Yea
If you can help I will really appreciate
nedbat mentioned
wat
you said ned
o
To help share my public project on Reddit too that's all
Owie
-# yeah
Hello dawg
Hello you
What type of API
I don't know
Ask Dawg
I think it'd be really cool if someone made an API for beehive environmental monitoring and called it ApiAPI.
Tell me more
Or APIary.
I can create it if it's not that hard
Got free time on my hands currently
I don't think it's a weekend project
i hate AI...i asked it to check the factuality of a convo and it argued with me until i proved it wrong.....sometimes it's genius ...sometimes it's like it's talking to a comatose idiot ..which then makes me suspicious of any complicated math questions i have for it 
@charred tusk do you wanna help π (am talking about the Reddit post)
Use a better model
Or some web service that gives you pictures of spiderwebs.
I wish I had some honey right now.
I could with some sweetness in my life
After the cold, bitter week.
what's better than GPT 5.5?
you just eat honey?
Yeah
Opus 4.7
Why wouldn't I
lmao lemme i have Opus lemme try with it
36,588
384,623