« first day (4234 days earlier)      last day (697 days later) » 

7:49 AM
That website is indeed great, helped clear up some things for me
Also like this quote which I think kinda encompasses what others said here before:
> There’s a crucial lesson here: design principles like Composition Over Inheritance are, in the end, more important than individual patterns like the Adapter or Decorator. Always follow the principle. But don’t always feel constrained to choose a pattern from an official list.
 
Sounds legit. Although inheritance has a lot of uses too.
 
"composition over inheritance" always sounds like "apples over oranges" to me
 
I personally find it a lot easier to wrap my brain around composition, but that's a problem with me rather than inheritance
and to be fair apples are better than oranges
 
especially if you want to make apple juice
 
8:07 AM
If I were held at gunpoint I'd name both composition and inheritance as patterns, and tell the person to choose depending on the use case
 
Whoever coined the phrase "comparing apples to oranges" should've picked two things that are less similar than two pieces of fruit. Something like "comparing paperclips to dinosaurs" for example
 
dinosaurs beat paperclips hands-down though
 
Not true, dinosaurs went extinct before paperclips even existed. Paperclips are the clear winners here
 
Statistical fluke. 99 out of 100 universes has dinosaurs and no paperclips.
 
Ugh, fine, I concede. You have outsmarted my outsmarting
 
8:25 AM
I could not find any good examples of how to execute some code paths as the regular user when the script is being run with sudo; do we have any canonicals or other good resources for this? stackoverflow.com/questions/72309604/… needs an answer but I'm thinking there must be a duplicate
@AndrasDeak--СлаваУкраїні I forgive you for you clearly have no idea what you are doing
 
@tripleee Side note: why is that process running as root...?
 
not familiar with the keyboard module but the author alleges that they need to be root to take over the device, which doesn't sound completely crazy
 
The last time I needed this I didn't find a proper solution. Ended up using sudo, AFAIK.
 
the os.setuid() etc change the entire Python process so I guess they would need to run unprivileged code as a subprocess, but that sounds extremely iffy too
 
@MisterMiyagi I'll allow it then
 
8:31 AM
I was hoping there would be something like with privileges(os.geteuid()): ... but drew a blank while searching
except that's the wrong os. function, too lazy to look it up now
 
Since they're starting a subprocess anyway for the shell script, running that via sudo should be rather straightforward.
 
yeah, but the part which writes the files should also be run as the real user, otherwise they will end up with root-owned files in their home directory
looking at the sudo manual I guess one would switch back to os.environ["SUDO_USER"]
 
"just chown them" ^^
Anyway, I agree that the proper solution would be in-process privilege management. AFAIK that's not (simply) possible, though.
 
with all the mkdirs etc you end up having to retrace what was done as root; and anyway, the real lesson is to run as little code as possible as root
 
"To avoid depending on X, the Linux parts reads raw device files (/dev/input/input*) but this requires root." Hm...
Reading up on capturing keyboard input a bit makes me very happy not having to bother with user input in my programs.
 
8:53 AM
Is async hell that much better a lot?
 
9:12 AM
I'm tempted to say "definitely yes".
 
(I posted an answer now, but feel free to ignore me, as the question is not yet 48 hours old)
 
At least async has the excuse of being rather new. Keyboards seem to be around for a bit longer...
 
then you have the legacy problem instead, there are thousands of implementation variations and you have to be aware of them all
 
It just seems a bit fishy that Linux apparently doesn't seem to have a reliable non-root way of receiving keyboard input.
 
9:24 AM
Why would a regular user want to receive keyboard input?
:P
 
Instead of manually hacking together global keyboard hotkeys with python, that person should just go and figure out how to create a global hotkey in their Desktop Environment...
 
ctrl+number might be intercepted by whatever window is in focus
 
Surely a global hotkey would take priority over a window?
 
If "global hotkey" is a special, magical thing, then sure. If it's just a regular hotkey defined in e.g. gnome, I'm not so sure. But I can't remember if my former woes were about the window intercepting the hotkey or the window not receiving the hotkey :D
 
Pretty sure it's the latter
 
9:31 AM
could be, I don't remember my last such fight
 
9:41 AM
yeah, I just tested with gnome, and the global one takes precedence
 
9:56 AM
Ah, yes. I remember what I ran into earlier. Some windows had keyboard shortcuts involving the "windows" button, but that triggers a window switcher in my gnome. I had to press alt along with it to break the global shortcut.
 
 
2 hours later…
12:11 PM
Hello. I have a class with this definition:

class Level(Flag):
    INFO = auto(),
    DEBUG = auto(),
    WARN = auto(),
    ERROR = auto(),
    FATAL = auto()

I use this class as a filter in a function, but I want the default value to be that it accepts all enums by using the bitwise operation:

def func(level: Level = (Level.INFO | Level.DEBUG | Level.WARN | Level.ERROR | Level.FATAL)):
     pass
Is there a shorthand for setting all bits/flags to 1?
 
sum(Level) should work
 
Yes, that works. The only thing I needed to change was Flag -> IntFlag
Thank you! :D
 
how to type annotate a function that takes a type and returns the same type, this type can be anything
def foo(x): return x + x how do I type annotate x and the return value?
I dont think Any is the way to go here
 
from typing import TypeVar

T = TypeVar("T")

def foo(x: T) -> T:
    return x + x
Something like this?
 
I did come across that, so the T here can be anything? or is it only one T?
T = int, T = float, T = str and so on
 
12:18 PM
Yeah, you can set restriction to the TypeVar though.
One seconds, I'll give you an example of usage
 
i guess this is what I want
 
Example from stackoverflow.com/questions/67685439/…:

from typing import Type, TypeVar

class Animal: ...
class Snake(Animal): ...

T = TypeVar('T', bound=Animal)

def make_animal(animal_type: Type[T]) -> T:
    return animal_type()

reveal_type(make_animal(Animal))  # Revealed type is 'main.Animal*'
reveal_type(make_animal(Snake))
I don't think you need the Type[T] in the function signature, just "T"
But I'm not 100% sure.
 
thanks, I will change if it does not work
whenever I look into type annotations, I realize why I stop, things like covariance, invariance always throw me off
 
 
2 hours later…
2:49 PM
Can someone confirm that just having the catch_warnings context leads to the warning being shown again and again?
import warnings

for _ in range(5):
    with warnings.catch_warnings():
        pass  # doing this on purpose, I swear!
    warnings.warn("This should appear only once")
 
huh
 
It's really not only on my messed up system then?
 
 
2 hours later…
user18470316
5:13 PM
I'm trying to write a compiler program for a specific grammar I defined.

There are a few ε in the grammar because of some iterative and recursive rules. I tried to define ε by creating an empty token but it causes some parsing problems, therefore I ignored spaces earlier in the lexer code. What are other ways to describe define ε?
 
@euleriscoding please don't ask for help with questions that were recently posted on the main site sopython.com/chatroom
 
user18470316
ok sorry:/
 
You should also include the code in the question body, see MCVE
 
@MisterMiyagi Can indeed confirm
After just having spent an hour or so hunting down a bug in LLVM code that was caused by the use of an 1-bit int instead of a 2-bit int, that question was easy. Can I have more of those?
 
5:41 PM
is pi^7 rational?
 
It's probably not very common in normal countries, but I've heard stories about professors letting students pick their exam questions blindly and at random with easy ("lucky") questions mixed in, like "What's the name of the teacher?", "What's the name of the subject?", etc.
What's your display name on Stack Overflow, Aran-Fey?
 
"due to the way floats are defined in programming languages there are no irrational numbers" https://stackoverflow.com/questions/4266741/check-if-a-number-is-rational-in-python-for-a-given-fp-accuracy
:P
 
@Kevin I don't know, but asking me that question is irrational! :P
 
I'm pretty sure (pi xor 7) is irrational. pi to the power of 7 is trickier.
 
@vaultah Oh, I know this! *raises hand excitedly* Me, pick me!
 
5:54 PM
hahahaha
 
@Aran-Fey are you sure? It might be a trick question
 
Yes, it's Aran-Fey!
I'm basically this woman right now :D
 
Oh, I didn't know there was a sequel. I feel substantial closure.
 
@Aran-Fey took me a day to mre, so don't hold your hippogryphs on getting another anytime soon.
 
Will this bug get fixed? No, of course not. Another easy one
 
6:02 PM
@Aran-Fey WTF
 
The video probably makes more sense if you've seen the prequel
 
6:38 PM
Right, I think I got it now
@Kevin Concerning the math or the Python's math package?
 
The math.
 
Ok :P
 
math.pi is a normal float; all normal floats are rational; the product of any two rationals is rational; positive integer exponents are merely products in disguise; therefore, math.pi ** 7 is rational.
subnormal floats are possibly also rational, but I don't care to check
 
Yeah, perfect
 
7:34 PM
Sorry, but why is hard or something like that to represent irrational numbers in a programming language?
 
For much the same reason that they're hard to write down on paper.
 
π, done
 
Now do it with only digits and arithmetic :-P
 
Should be easy, I'll let you know when I'm finished
 
>>> import sympy
>>> sympy.pi
pi
>>> sympy.pi.evalf()
3.14159265358979
>>> sympy.pi.evalf(100)
3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068
Was it really that hard?
 
7:45 PM
I need way more digits than that :-)
 
I was even thinking about doing something concerning it with SymPy, but from the research I had just done, you can do the same with Python itself: realpython.com/python-fractions/…
 
@AndrasDeak--СлаваУкраїні I can verify that value by eye. ;)
 
@MisterMiyagi this reminds me of opening SQL connections with a context manager and the connection still being alive after you leave the context
 
I have an SO answer that does large numbers of digits of pi, using the decimal module.
 
The context manager opens the connection but closes the cursor on the connection. Because, obviously it should
 
7:49 PM
I bet it's not all that hard to design a format that represents arbitrary algebraic reals. You could even throw in the more famous transcendentals like pi and e. But I doubt it would be efficient in all circumstances.
 
Why doesn't float type include irrational numbers?
 
@Kevin Nope. pi is transcendental, so it's not the root of a ploynomial function with integer coefficients of any finite degree. If pi to the 7th were rational, then pi would be the root of a 7th degree poly with integer coefficients.
 
@Marco The more kinds of numbers you have, the less precision you can have for each one.
 
@Kevin Sage has that.
 
(warning: oversimplification)
 
7:52 PM
@Kevin Really?
I had forgotten that you considered it in relation to the math as a whole, and not in relation to the answer that Python gives in float
@PM2Ring I think you are right
@Kevin Right, I think I got it
 
Sage also allows you to define symbolic values. So you can manipulate expressions involving pi, e, and algebraic numbers, and it keeps track of it all. This can be useful, but it can also be really annoying when you don't want it to do that. You have to explicitly tell it to perform a numeric evaluation on stuff. :)
 
@PM2Ring Python's SymPy package also do that
 
If by "really?" you mean "I'm incredulous that you consider it difficult to prove whether pi to the power of 7 is rational", gimme some slack, they never covered that in math class ¯\_(ツ)_/¯
 
Yeah, Sage uses SymPy, and (mostly) hides the messy details.
 
@Kevin I did not mean that, I mean that I think that pi to the power of 7 is irrational
As the PM 2Ring answer's says
 
7:55 PM
Hmm I see
 
@PM2Ring Nice
 
Expanding upon my message about the efficiency of an irrational type... Since there are an infinite number of irrationals, you can only represent all of them if you're willing to consume an indefinite amount of memory. For example, x = 2; for i in range(1000): x = sqrt_as_irrational(x) might take up 8000 bytes or so.
Or maybe that's a bad example... Perhaps the sums of the square roots of the first billion primes, then. I don't think that's reducible.
 
Right, but there could be an Irrational type for people who want the irrational result easily
 
Well, it's kind easy to prove that pi^7 is irrational if you're allowed to assume that pi is transcendental. If you have to *provej that pi is transcendental, that's rather tricky.
Proving that e is transcendental isn't so bad... if you've seen the proof. ;) I've worked through the proof & understood it to my satisfaction, but that was 4 decades ago. I've seen the proof for pi, and I kinda sorta got it. I think. But I doubt I could prove it myself without expert assistance.
 
Once you've got a gigabyte-sized irrational, it's not so easy to do certain things with it. For example, if my_irrational > 100: might take a huge amount of time to run. Compare with floats, which always take up the same amount of memory, and are almost guaranteed to execute if my_float > 100: with lightning speed in all cases
 
8:02 PM
Kevin, pi to te power of 7 is rational or irrational?
 
It's probably irrational.
 
hahaha :P
Right
@PM2Ring Nice
@Kevin Good
 
If you don't pay attention in Sage when working with irrationals, you can find your loops suddenly slowing to the speed of treacle. You throw in a print call, and realise that your value is now some complicated thing with thousands of terms. :)
 
Nice
 
Fast Python code for lots of digits of pi: stackoverflow.com/a/26478803/4014959
 
8:07 PM
"some complicated thing with thousands of terms", sounds like my ex wife, heyooo
[disclaimer: I do not have an ex wife]
 
Kevin's current wife glaring in the background...
 
And concerning the irrational complex numbers? Python support them?
 
Not in the builtin types, no. I'm sure a sufficiently determined coder could make a custom type if they wanted.
 
Slow pi digits, only using integer arithmetic: math.stackexchange.com/questions/1295373/…
 
@Kevin Right
 
8:14 PM
@Kevin That could be a Borscht Belt joke...
 
https://chat.stackoverflow.com/transcript/message/54605717#54605717 and https://chat.stackoverflow.com/transcript/message/54605736#54605736 :

Awesome references, PM 2Ring
 
I like pi. But I like several other irrational numbers, too. :)
 
liking irrational things is peak human
 
There's an irrational number that comes from a sequence that's closely related to the Fibonacci sequence. The Fibonacci sequence gives us the golden ratio, the positive solution of x^2 = x + 1. This other number is the real solution of x^3 = x + 1. It was studied in the late 1920s, and got called the plastic number. The connotations of that name haven't aged well. ;)
 
8:31 PM
I think not aging at all is the main problem
 
@Marco That's no different to the "problem" of getting tiny values when working with floats, when exact real arithmetic gives zero. It's just slightly messier to deal with when you're working with complex types. But there are often library functions to zero out tiny complex parts.
 
Yeah
What is the reason for people to be computing a lot of pi number houses and similar things? I am not remembering... I think it has to do with cryptography...
pi decimal places*
 
it has to do with street cred
that, and the hope that eventually Sonnet LXXV will pop up
 
?
 
Noun: street cred (uncountable)
  1. (slang) Credibility among young, hip urban dwellers; particularly important in the hip-hop and rap scenes.
you get cool nerd points if you can compute pi to a lot of decimal places (and it probably has some side-effects through mathematical and programming tricks for optimizing the problem)
 
8:45 PM
cool nerd points?
 
one high-rep SO user was a record holder for a while, the links in their profile might give additional hints stackoverflow.com/users/922184/mysticial
@Marco the kind of points measured in other nerds saying "hmm, cool"
 
@Marco It's traditional! A few people computed pi to several hundred digits by hand in the days before computers. So it was natural for some early coders to write programs to compute lots of pi digits, to verify those old results, and then set new records. It was a big deal for programs to pump out a few thousand digits of pi on machines with only a few kilobytes of RAM.
 
Nice, thanks to both (but the street cred's part I don't get it)!
 
There are lots of different ways to calculate pi, so it's a good way to test your arbitrary precision arithmetic code. You calculate pi a few different ways and see if they agree.
 
But as I recall, this has useful(s), functional(s) aspect(s)
Related to cryptography, I think, at least
 
8:51 PM
@Marco It's like climbing Mt Everest. The world doesn't need people to climb Mt Everest. But the ones that have done it can brag about it. ;)
There isn't much point in using digits of pi in crypto. You're better off using less well-known digits.
 
So there is nothing useful about it?
 
OTOH, I have used digits of pi as a PIN number, and as a simple way of making pseudo-random sequences by hand.
 
I think I'm missing something in my python knowledge. Does anyone know how this works in Cpython? new_position = random.randint(*self.swap_bounds[po_code]). I wrote it, and I know it works and does what I want, but the complexity of making it work has also just struck me. I think this is beyond just parsing the grammar?
 
@roganjosh which part?
self.swap_bounds[po_code] is an iterable that gets unpacked as positional args into randint()
lohi = (4, 42)
randint(*lohi)  # randint(lohi[0], lohi[1])
 
*self.swap_bounds[po_code] becomes a tuple, but foo(a, b) has a and b that aren't strictly a tuple themselves?
In a tuple*
 
8:59 PM
no, it does not become a tuple
(*foobar,) becomes a tuple. foo(*bar) becomes unpacked args.
 
Right, so the splat operator here has distinct functionality when it's in the args of a function call?
 
@PM2Ring Right, nice, thanks!
 
@roganjosh not sure what you consider to be distinct functionality, but yeah, the tuple version was enabled in peps.python.org/pep-0448
 
I'm struggling to pinpoint my surprise at this, but it's only just hit me. The behaviour is predictable but the underlying mechanics seem wildly different
 
One is a function call and the other is a literal(?), so the semantics are clearly different. The syntax too for that matter, because only one of those is a function call (duh)
and then there's def foo(*args) which is a third, but similar thing
 
9:04 PM
@AndrasDeak--СлаваУкраїні got it in 1, thanks! Sorry for being vague
 
and there's also peps.python.org/pep-3132 which might or might not be different
 
9:16 PM
I do enjoy these moments. Stuff I take for granted and then get a "hold on one sec" moment. Thanks :)
 
BTW, randint calls randrange, so it's more efficient to call randrange directly. OTOH, some people find randint(1, 6) more readable than randrange(1, 7). :)
 
These inty random APIs always force me to look up the documentation...
 
I think randint was a bad idea, but it's far too late to get rid of it now. To me, it makes sense to stick to one convention for ranges & slices.
 
@PM2Ring I only call it 1 million times in a tight loop... barely matters :P Good info, thanks!
 
No numpy in the codebase?
 
9:23 PM
Almost all of my random numbers can be pre-generated and still be cheaper than calling in each iteration of the loop, but this particular one needs upper and lower bounds
 
Maybe use Numpy, and create an array with a million random ints in it. It will be much faster.
 
We're all on the same page :)
 
except the "needs upper and lower bounds": you can still do that pre-generated
 
Ah, if you don't know the bounds beforehand, then I guess you need a loop.
 
and make sure you use the new random API
(the one that goes rng = np.random.default_rng())
 
9:26 PM
Let's say I want to run my solver for 10k iterations, and it can pick between A and B. Within A and B I need a new random number for the next choice it makes. I don't fancy making 10K selections for the next level down when I already know that, on balance, I'll only need 5K at best. Now extend that to the whole alphabet and more
 
What Andras said. Numpy now uses PCG by default, which is much faster, and better quality than stdlib random (Mersenne Twister).
 
@roganjosh OK, but that sounds less like an "I need bounds" problem and more like an "iteration depends on the previous iteration" problem
 
So if the outer RNG picks A, I can select between 0 and 10, but if it selects B I can select between 2 and 5 (for argument's sake). I don't care about RAM. But generating 10K of each of the secondary selections is weak
 
Well if you do have RAM then you could still do it. Trading RAM for CPU time is the basic goal here after all.
 
That would give me full coverage to make the second level of random choices for every single iteration of the outer loop, but I know they'll be wasted
 
9:30 PM
assuming it ends up being faster
 
I don't think it will. I have tested it in the past, but I haven't tested the speed in this specific context
But, fair point
 
There may be an efficient way to do this, depending on the size of the ranges at each leve.
 
Genuine comment from the code I'm handing over:
Calling random.choice or np.random.choice in a loop is expensive.
Instead, it's actually cheaper just to make all our choices up front in
a single call. We want to determine:
    -   Which PO we want to swap on each iteration
    -   What we we want to swap that PO to
But in c/p'ing that, I truncated "week" to "we" for efficiency :P
 
I don't know what PO means.
 
you could probably generate array indices instead of the actual values, in which case low/high in rng.integers can broadcast to the number of A/B samples
low is 0, but high is n_A_options if you got A and n_B_options if you got B
 
9:34 PM
Purchase Order, but it's not important. Point is, I know how expensive it is to keep calling for random numbers so I do as much in bulk as I can
 
hmm, assuming we can use those indices efficiently... you'd need a boolean mask to pick out the two riffled index arrays
I guess your np.where might help :P
Except you'd pass in eagerly evaluated indexed expressions, leading to errors... Oh well. Might be worth investigating if you're hard-pressed for optimisations.
OK, just loop over the random array indices and evaluate them in the loop...
 
@AndrasDeak--СлаваУкраїні Nah, I have my new friend Rust if I was against the wall :P This only came out of me looking at the unpacking operator and thinking "hmmm, this is consistent in my expected behaviour but this is definitely doing different things depending on its context"
 
On a similar note, subscription syntax doesn't allow unpacking: arr[*indices] is a syntax error. However, you can get around this by doing arr[(*indices,)], because this builds a tuple, and arr[i, j, k, ...] is just syntax sugar for arr[(i, j, k, ...)] so it will work.
 
Eg, if the outer loop needs random ints from range(100) and the inner loop needs ints from range(50), you could just generate a big pool of range(100) numbers, and divide them by 2 (or bitshift) them for the inner loop.
OTOH, PCG is pretty fast, so it's probably cheaper to just generate fresh randoms in the proper range, rather than doing (say) 2 or 3 arithmetic operations on existing random numbers.
 
That's not really the flow, but I'm gonna struggle to make a succinct explanation :/ The solver picks a PO at random and each PO it picks will affect the stock (it's a shipping container that we can pull in earlier than planned, or push back). But, there are limits, right? I can't pull in a container earlier than the product within it can be produced, and I can't push it back further than, well, infinity
All of this works, btw
But the outer loop selects the container. The inner loop needs to draw from the range of possible dates for that container
So, the RNG for the outer loop is easy - we can pre-generate to select the container. But now we've selected the container, it has its own range from which to draw from. It's not so attractive to generate all those options for every iteration
So, the outer loop can be pre-generated but the inner choice of moving the container you've just selected on this iteration is better done on-the-fly
 
9:51 PM
I did give an alternative, but I get it that you're happy with what you have
 
I saw your comment about masks but I didn't get it, sorry
 
In the inner loop, do you use random.choice? Or can you use randint?
 
haha, full circle :p random.randint(*self.swap_bounds[po_code])
 
I assume the randomisation doesn't have to be mathematically perfect. That is, the probabilities don't need to be exact.
 
Nah, not at all
 
9:56 PM
A_vals = [-2, -5, -3, -4, -10, -8]
B_vals = [4, 42]
n_samples = 20

letter_types = rng.integers(0, 2, n_samples)  # 0 for A, 1 for B
highs = np.full_like(letter_types, fill_value=len(A_vals))
highs[letter_types == 1] = len(B_vals)  # or np.where
sub_types = rng.integers(0, highs, letter_types.shape)
>>> letter_types
array([0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0])

>>> sub_types
array([4, 3, 4, 0, 1, 0, 2, 2, 5, 0, 3, 2, 3, 0, 0, 0, 3, 0, 2, 4])
So you loop over (letter_type, sub_type) pairs, and use [A_vals, B_vals][letter_type][sub_type] in your loop. Just more efficiently.
 
... This looks seriously cool
 
cool is one thing, question is whether it ends up being faster :P
You pay the cost of building highs (not terrible, but we're trying to shave off small times), and even if you pre-define the [A_vals, B_vals] list or equivalent the double indirection might still end up being slow. Oh, and looping arrays is not great for performance.
 
It's gonna take me a bit of time to get back to you on that, but I like the look of it
 
So I'd also time the same thing, but looping over letter_types.tolist() etc.
@roganjosh no rush, I'm just musing
>>> arr = np.arange(10_000)
... lst = arr.tolist()
... %timeit sum(i for i in arr)
... %timeit sum(i for i in lst)
863 µs ± 8.93 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
288 µs ± 2.07 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
less than 0.6 ms for the whole loop, so probably not worth the ugliness
(and the conversion might take longer overall)
anyway, I'll leave you alone now :D
 
Quite the opposite of bothering me, you might have flattened my nested choices. It's gonna take me a bit to feed back but thank you :)
 
10:24 PM
@AndrasDeak--СлаваУкраїні I think this only works for one product, or individual products, in which case where do I stop? If I want 100K iterations of the solver, selecting from a pool of 100 products, do I do this 100,000*100?
There is no lookup for the particular product selected
 
@roganjosh it works for a given configuration of products (assuming A and B are products). So for 100k iterations you first generate 100k integers choosing a product, and then 100k integers corresponding to random indices within each respective product.
Assuming I'm not missing the use case.
I don't really know how "iterations" and "products" relate, obviously
 
@AndrasDeak--СлаваУкраїні But A can only select from between 2 and 5, and B from only between 8 and 9, let's say
So there is a dependency
 
Yes, that's what highs does: it chooses an appropriate integer index range for each sample. If the first out of 100k samples was A then it chooses an integer index between 0 and 3 (for [2, 3, 4, 5]). If the first sample was B then it chooses an integer index between 0 and 1 (for [8, 9]).
so the state space for the first sample (iteration) would be:
product 0 0 0 0 1 1
subtype 0 1 2 3 0 1
If you look at chat.stackoverflow.com/transcript/message/54606161#54606161 you can see that where there is 0 in the first array you have larger maximum values in the second array, and where there is 1 in the first array you only ever have 0 and 1 in the second array, because B_vals = [4, 42] only allows two values.
 
I'm missing something, sorry. I don't want to frustrate you but B_vals = [4, 42] is throwing me when all the values are <5
 
10:32 PM
array([4, 3, 4, 0, 1, 0, 2, 2, 5, 0, 3, 2, 3, 0, 0, 0, 3, 0, 2, 4])
 
yeah, because those are array indices, see chat.stackoverflow.com/transcript/message/54606166#54606166
>>> letter_types
array([0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0])

>>> sub_types
array([4, 3, 4, 0, 1, 0, 2, 2, 5, 0, 3, 2, 3, 0, 0, 0, 3, 0, 2, 4])

>>> for letter_type, sub_type in zip(letter_types, sub_types):  # zip probably avoided in prod
...     print(f'I have product index {letter_type} ({"AB"[letter_type]}), and within subtype index {sub_type} ({[A_vals, B_vals][letter_type][sub_type]})')
I have product index 0 (A), and within subtype index 4 (-10)
I have product index 0 (A), and within subtype index 3 (-4)
 
Thanks. I think I've perhaps enjoyed Friday too much after this week so I might be best picking this up another day
 
10:51 PM
This chat room is made in ASP.NET, right?
(and all the others Stack Exchange's chat rooms as well)
 
@Marco see this
 
Yeah, TY, that reference that was in my mind, and as I thought, is made in ASP.NET ("Web Framework ASP.NET Core 3.1 with MiniProfiler")
The strange part is that is mentioned only the SO in the answer
 
As opposed to..?
 
Stack Exchange
 
You've lost me, sorry. I don't know what you're asking or remarking about
 
11:04 PM
But probably they are all made the same way (at least apparently)
@roganjosh I am only commenting about the chat rooms in other Stack Exchange's sites, beyond the Stack Overflow ones
But that reference perfectly answers my question
The detail is because I've added this observation: "(and all the others Stack Exchange's chat rooms as well)"
 
Hi!
Working with playlists is really tricky, because one playlist may include other playlists.. :(
 
Really?
 
Yeah, and the complexity is sizing very if you thought that one playlist may include a retransmition.
 
I did not know that a playlist may include other playlists
 
11:21 PM
It's rare but it may exist in some cases..
 
Cite one example, please
 
Hmm
Right
Thanks
Interesting
 
For retransmitions items i have three cases: const url (exact the stream url), dynamic url (url of site + javascript code that evaluate the stream url) and youtube url of live stream.
And for the three cases i start a process (ffmpeg) that writes to a file the live data, then i read the file per chunk.
 
11:56 PM
Nice
 

« first day (4234 days earlier)      last day (697 days later) »