« first day (4641 days earlier)      last day (500 days later) » 

01:41
@lyxal no here copilot is giving you advice about how to let the compiler optimize your code and get rid of those expensive branching instructions
:p
 
5 hours later…
06:31
Is there a easy way to find the most recently deleted answer in the sandbox?
You could scrape every page until you find a deleted post
You'd need the scraper to have 10k+ rep access though
If you had a code golf diamond it'd just be deleted:1 inquestion:2140 :p
06:57
@mousetail can't you just scroll to the bottom of the last page? Seems to be that the most recently deleted answer is codegolf.meta.stackexchange.com/a/26071
07:15
@Neil Bottom of the page is the oldest deleted answer, the newest is pages and pages back
@lyxal Ok brb going to grab a diamond
@Neil That does seem to be the post thanks
@mousetail sorting by date created puts it on the last page
That makes sense thanks
@lyxal Ah right, I use that sort by default, since that used to mean that posts would never change page
if you don't want to change your sort order, open the sandbox in a logged-out window and find the last page of regular questions that way
08:09
Dim question, in codegolf.stackexchange.com/a/265865/116117 why write out the logs explicitly instead of using the log2 function?
Is there some advantage to writing them out explicitly?
 
2 hours later…
10:23
ah.. the painful weekend silence
it'll do be is like that's how it is
your grammar has confused me!
10:45
nyeh heh heh :p
do you understand why codegolf.stackexchange.com/a/265865/116117 explicitly writes out LOG3 etc?
why not just compute it there?
it's probably faster to just have a constant than to perform computations
it is a fastest code challenge after all
but I don't mean do it in one of the loops. Is const double LOG3 = log2(3); not allowed?
I know no C++
 
1 hour later…
12:16
@mousetail your rust answer has exactly the same number of upvotes as the C++ answer
12:58
Now I need exactly the same performance
13:37
@Simd Speed, again. Which is faster for you to evaluate, 9 or 3*3?
@TheEmptyStringPhotographer It will be the exact same because constant folding
Google constant folding
Hmm, ok…
But this wouldn’t apply to interpreted languages…
It can, interpreted languages can do some optimization, if they have a bytecode or JIT or something
this is C though, so it's guarenteed to happen
>>> import dis
>>> dis.dis("3*3")
  1           0 LOAD_CONST               0 (9)
              2 RETURN_VALUE
>>>
Even in python 3*3 is exactly the same bytecode as 9
In C you can mark functions as constexprwhich means they can be evaluated at compile time for constant folding and other optimizations, in python it only applies to basic operators and maybe some basic builtin functions
14:01
@mousetail holy hell
I love how chess has coopted major corporation into a meme
@TheEmptyStringPhotographer but they would only be computed once
@mousetail I didn't know that!
In [7]: dis.dis("math.log2(3)")
1 0 LOAD_NAME 0 (math)
2 LOAD_METHOD 1 (log2)
4 LOAD_CONST 0 (3)
6 CALL_METHOD 1
8 RETURN_VALUE
I guess python doesn't fold that constant
Yea python doesn't normally fold functions
You could have hypothetically assigned something different to math.log so it would have a different result
so it can't be folded safely
14:17
@mousetail i guess it could know about its standard library. I mean it could know that math.log2 of an int computes a float
or is that too naive?
No you don't know that, you could literally do math.log2 = print and it would work
then it would return None
ah... python :)
That's why attempts like Mojo to turn python into a performant language are fundamentally hopeless
you can't optimize much
can the interpreter not tell that math.log2 has its original definition?
is mojo even available to the general public yet?
just installed mojo
I have no idea how to use it!
@mousetail the charcoal answer is only just behind yours and the C++ one!
@Simd Not at the bytecode compilating stage, pypy might be able to it during incremental JIT but still it would need to insert a check every time which will be slow
14:31
@mousetail how come it can't be done at the bytecode compilation stage?
is it hard to tell if math.log2 has been redefined anywhere?
@Simd because you dont have to do any linking
@Simd yes
suppose its been redefined in a library hidden somewhere, or with metaclass magic or whatnot
ah...
in my language its even worse because i cannot assume that the operator + for numbers hasnt been overridden
so i cannot assume that 1 + 1 can get folded into 2 because it might be 11
@Seggan :) which one is that?
14:43
Can constant folding work for log in C++?
This is good
Does c++ have a function for bit length?
15:00
In C++ you can mark any function as constant foldable with constexpr
doesn't mean the compiler will always do it though
m90
m90
@Simd Yes, since C++20: std::bit_width (found from the duplicate question from your link)
there is some weired edge cases around floats that make it sometimes really hard to guarentee the operation will have the same result at compile time and run time
 
2 hours later…
17:17
@m90 that's great!
@mousetail nice
 
5 hours later…
22:13
I really want to know how assuming the Riemann hypothesis is going to help with my challenge
22:25
Is there a C equivalent for constexpr to allow constant folding?

« first day (4641 days earlier)      last day (500 days later) »