« first day    last day (23 days later) » 

12:07 AM
Hey Alex
I did mention why I utilized is vs ==, which was for speed. I perfectly understand and welcome criticism -- what I don't enjoy is a sense of entitlement towards others, which you provided from the gecko of the conversation.
 
Wait is there actually a significant difference in performance?
 
I don't think either of us in here to argue the semantics of our sentences. What I can tell you is that your "criticism" came off as aggressive from the beginning, and that is what confused me.
A few microseconds, yes.
 
I'm sorry, I did not mean for my comments to be aggressive :/
 
```python
import timeit

def func1():
return "1" == "1"

def func2():
return "1" is "1"

print(timeit.timeit(lambda: func1(), number=100000))
print(timeit.timeit(lambda: func2(), number=100000))
```
Sorry for my misunderstanding then. They rubbed me off the wrong way, and I tried to keep composure until I think we both lost it. I always assume the best in people, and I think we just started off in the wrong foot
 
Yes, I think you're right :)
 
12:17 AM
I suppose code formatting does not work here
 
import timeit

def func1():
return "1" == "1"

def func2():
return "1" is "1"

print(timeit.timeit(lambda: func1(), number=100000))
print(timeit.timeit(lambda: func2(), number=100000))
hmm yeah that's barely any different (hitting the "fixed font" button before sending)
 
What tag did you use? Used to the ```
Let me mention tho: I do appreciate us both hopping on here and clearing up the air
In the end of the day, I wish the very best for everyone I interact, online or offline-- so I do appreciate you taking the time of your day to message me through here
 
So do I
:) <3
import timeit

def func1():
return "1" == "1"

def func2():
return "1" is "1"

print(timeit.timeit(lambda: func1(), number=100000))
print(timeit.timeit(lambda: func2(), number=100000))
 
Okay it looks like CTRL+K does the same thing as the "fixed font" button
 
12:20 AM
Since we are here, let me do say that I do agree that your code does perform better, and at some earlier point, I even mentioned to the OP that perhaps bitwise operations would be best
 
@FelipeFaria I know, and I appreciate that
 
I was just browsing StackExchange and saw that question, and quickly wrote a solution that I knew was already gonna work without bothering sitting down and doing bitwise
 
I didn't share it in the post, but I actually tried to find a more efficient to generate the powers of 2.
def gen_pows_2():
    curr = 1
    while True:
        yield curr
        curr = curr << 1

def bin_str_decomp_2(bin_num_str):
    bin_num_str = bin_num_str[:1:-1]

    res_lst = [curr_pow for curr_bit, curr_pow in zip(bin_num_str, gen_pows_2()) if curr_bit == '1']
    return res_lst
Strangely enough, it seems to be about 50% slower!
 
Frankly, in the projects I work on I haven't personally had use for bitwise operations, and so I never bother to truly dive into them to have that innate logic to em
 
It certainly isn't something that we need often.
 
12:23 AM
I think it might be the zip, if I had to assume
 
I mean I could have used **2, I didn't simply on the off chance that it wouldn't be transformed into a shift.
 
For testing, I also created a cached dictionary with the binary representations of numbers from (0, 1000) and compared that against both of our solutions, and expected, it worked O(1) speed
[0, 1000] if we gon be exact 🙄🤣
 
That's probably the best solution tbh. If you know that you're going to be needing a lot of powers of 2 you might as well
 
Your original solution, that is
I agree. But your solution's slope scales extremely slowly
It's super-fast, even for very large numbers
Unless the OP has intentions of only converting within a range, I definitely think your original solution is the most optimal
I'm sure there are some weird Python semantics neither of us is aware that could speed it up (some of the stuff you see the core devs throwing at people on the highly upvoted questions on some specific performance prioritized question, if you know what I mean)
 
Man I honestly have no idea what OP is up to lol. I wish he had spoken a bit more about what he was doing.
 
12:29 AM
Same, tbh. I honestly wrote my answer for the semantics of it -- the original answer was just "You could do something like this: [code]", and then I kept playing around with it to see how small I could make it
That's the thing about Stack Exchange
sometimes you get God's from different worlds (JS, C++, etc.) asking questions about Python, and you know for a fact some lazy answers just aren't going to do it... but then sometimes you get random folks that are clearly just trying to solve a specific (small) problem, and they don't even know where to start
 
yeah, true
 
The people on the first category, I usually take my time and inquire on the comments... the other folks, I usually just post a "lol, maybe this might be of help" kinda answer.
But hey man, again, I appreciate you hitting me up. I wish you the very best
I'm about to go grab some dinner with some friends
 
I'm trying to profile my alternative shifting solution, but it's not working since it's in 2 functions. I give up.
No problem, enjoy :)
Bon appétit
 
Flipping the string with [:-1] is a O(n) operation, if I remember right
nvm, your code doesn't work without the flip
Just read it
 
Is [::-1] worse than reversed()?
And yea I reverse the string, although I guess there isn't much of a need to. It would be necessary if I used the other solution, the one with the power of 2 generator
 
12:38 AM
I believe they work on the bases of the same code for the interpreter
but I might be wrong the point above ^^
Correct me if I'm wrong, but I don't think your function would work without reversing it due to the bitwise operator -- at least from a quick test of what you posted above (in the chat) and replacing the list for [2:]
I'ma get going, but I'm gonna revisit this at some later point
if you find something cool, lmk! Nice talking to you man
Sending you good vibes from Florida
 
Nice talking to you, goodbye!
 
 
15 hours later…
EAB
3:18 PM
hT is bascially my question. I thought the pow() function didn't do binary or modular exponentiation. I tried dividing and conquering, but it is still slower. If you can answer that question, I will solve my problem.
How can I efficiently get 1,000,000 to the power 1,000,000?
 
 
6 hours later…
9:06 PM
That's a tough one, I'll try to do some research
I doubt I'll be able to find anything that you haven't already :/
 

« first day    last day (23 days later) »