« first day (3806 days earlier)      last day (1158 days later) » 

7:27 AM
From @PSF Twitter: "Thank you to the 35 Pythonistas that have self-certified as managing or contributing members so far this month! Can we reach 100 by April 1? Yes! Participate in our membership drive - basic membership is free. Details can be found here: https://python.org/psf/membership/."

Self-certify as a Contributing Member if you spend 5+ hours/month on a free open source project, or Managing Member if you spend 5+ hours/month organizing meetups or other community activity.
3
 
I want to get into this but unfortunately I cant seem to find a project that would benefit from my medium expertise
 
 
1 hour later…
8:52 AM
@PaulMcG I would love to send this to him, but I don't dare yet :P
 
@Aran-Fey I want to keep asyncstdlib free of loop-implementation specifics – especially asyncio. ;) But if there is some more general use-case like retrying behind it, perhaps it's possible to do that in a loop-agnostic way.
Would be interested to know in how far you need explicit access to the loop. There should be an asyncio function to implicitly give you the concrete loop via the magic "current loop" lookup.
 
@AndrasDeak :D
 
@MisterMiyagi It's usually because I want to cancel a task from the synchronous part of my code via loop.call_soon_threadsafe(task.cancel)
Wouldn't be necessary if tasks had a get_loop() method, but alas
 
9:49 AM
Has anybody tried using: jetbrains.com/help/pycharm/… the pycharm debug server? It seems really involved to set up and a colleague told me they tried and didn't get it to work. Any experiences in here?
 
10:32 AM
numpy question:
ValueError: operands could not be broadcast together with shapes (768,1360,3) (768,1366,3)
so I want to get the left array to the size of the right array by just changing the right/bottom of these as these are RGB images...
if it needs to be expanded 0 is preferable over wrapping...
 
Not with broadcasting. You need padding. If you don't want to figure out how to call np.pad (I don't) you can do res = np.zeros((768,1366,3)); res[:, :inp.shape[1], :] = inp or variations thereof. With np.pad you'd probably have to pass something dumb like [(0, 0), (0, 6), (0, 0)] as padding width.
 
I do not want variations. The dimensions on the right hand size are right. I do not want to figure out which on the left hand size is wrong, as it could be anything :D
 
is the result guaranteed to be larger along every axis?
 
no
nothing is guaranteed.
 
then give up :P
 
10:41 AM
whatever happens is fine :P
 
I can offer a ValueError
 
no
valuerror is not acceptable.
the number of dimensions will agree
 
But what happens if the target has shorter dimensions along certain axes?
 
and I want to have shape of the right, with zeroes if not matched on the left, and if left is larger the shape of the right with largest indices cut out, and I want to have clean code that just works.
 
10:43 AM
basically I had an algorithm that worked with low res pic and now that I expand it to higher, then, in this case the dimensions of LHS will be /8*8 hence what you see there :P
but I don't care about the edges (that much)
they're rounding errors ...
 
res = np.zeros_like(inp, shape=(768,1366,3))
slices = tuple(slice(min(first, second)) for first, second in zip(inp.shape, res.shape))
res[slices] = inp[slices]
untested ^
 
that could work ...
 
well duh :P
 
It's easy with PIL:
arr = numpy.ones((5, 5, 3), dtype=numpy.uint8)
desired_shape = (8, 2, 3)

result = Image.new('RGB', desired_shape[:2])
img = Image.fromarray(arr)
result.paste(img)

result = numpy.asarray(result)
print(result[:, :, 0])
 
@Aran-Fey :(
@AndrasDeak I'll ask on Stack Overflow
 
10:57 AM
why?
 
pad the left to be equal or larger than right, then cut that intermediate result according to the shape of the right?
wow, numpy.pad is a lot more confusing than i was anticipating
 
The documentation for that function is impressively bad
 
it's too versatile
 
11:14 AM
makes sense
AD's approach worked like a charm though, don't need to do it in two steps
or er...i suppose dont need to do it in "3" steps, if you count creating the array with zeros as a single step
 
unclear; unlikely to help future visitors stackoverflow.com/questions/66451875/…
 
@tripleee you should be able to vote on it again, or maybe tomorrow
 
Apr 1 it says, I already have a pending close vote
 
> A better design altogether would be to have get_attachments accept the directory name as a parameter
Question
i've actually been using this pattern of a global for my own scripts for the "OUTPUT_ROOT" and then constructing further paths based off of that
is that considered a bad practice?
 
@tripleee weird
 
11:21 AM
globals are always slightly iffy, I usually try to make sure I write my functions so they allow me to pass in the destination file or directory and then where exactly it comes from is less consequential
 
hm, shouldnt be too difficult to change this habit on my part.
or so i hope
 
@Aran-Fey Ugh, that sounds tricky indeed. Can't think of a better native approach than having a coroutine store the loop in a (weakref?) global.
 
11:43 AM
Ooh, doing it the other way round is a good idea though. Instead of creating a loop and manually doing all the stuff asyncio.run usually does, I just wrap the coroutine in an object that lets me access the loop and run it with asyncio.run
Working with asyncio requires so many utility functions/classes, I'm not sure if I want to stuff them all into one single library or three...
 
I've pondered writing a nice-asyncio-primitives library. Don't have enough booze at home...
 
I wish people wouldn't upload so much garbage to pypi, it's near impossible to find something useful on there
There's no way nobody has written any asyncio helpers yet, but good luck finding them
> You can use @async_property just as you would with @property, but on an async function.
async_property = property, that's one library done, publish it!
 
12:08 PM
maybe that's what we truly need, a pypi's "approved" subset, with a search dedicated to just packages in that group.
 
As far as I can tell, most of the useful async helpers are buried deep in huge libraries/frameworks.
 
 
1 hour later…
user13727121
1:25 PM
How do I reuse the variable of a function in another function? Like in this example, dpaste.com/7BV7NXAP9, I want to reuse choice_yes, choice_no variables in my second function, but calling try_again() requires me to fill in the values of those two parameters when I only need the variables
 
@CoreVisional You can't (easily).
you could make those choices global names and access them from both functions
 
In that case, it's fine to make them global variables. Because they're not so much variables as they're constants.
 
just make sure not to mutate those lists anywhere
 
user13727121
ahh I see, thought there'll be another way instead of making it globals. That means I either make it global or write the same variables in my second function?
 
and you forgot the input from retry = input(...)
@CoreVisional or make both functions accept the choices as input parameters, and pass them with each function call
you'd still have the global name, but the functions would not access it directly
 
user13727121
1:29 PM
@AndrasDeak holy, thank you for noticing that, though it's only an example but still
 
user13727121
@AndrasDeak don't think I get it... so my functions would have the parameters def try_again(choice_yes = input(), choice_no = input())? Would it not be easier if I just move them to the global scope?
 
@CoreVisional by now you should realize how wrong it is to put input() into a function signature
and if you reread what you asked you might notice how you wouldn't want to ask for choice_yes and choice_no from user input, looking at your original code snippet
I meant keeping try_again as is, but calling it as try_again(choice_yes, choice_no) with those two lists put into the global scope
 
user13727121
Oh okay, that was just silly me, so basically it is something like this? dpaste.com/EFEZK8HU7
 
morning cabbages, folks
 
@CoreVisional that's the "use the global names" option
It's what I'd do. But you asked if there was a way to avoid globals, and that's what I've been telling you for a while.
Try carefully rereading all that I've told you starting here
 
1:45 PM
Honestly, the ideal solution would be to create a function that handles all yes/no questions.
def ask_yes_no_question(question):
    CHOICE_YES = {"Yes", "yes", "Y", "y"}
    CHOICE_NO = {"No", "no", "N", "n"}

    while True:
        answer = input(question)

        if answer in CHOICE_YES:
            return True
        elif answer in CHOICE_NO:
            return False
 
anyone here have access to a university's library? I'm looking for this paper
 
user13727121
@Aran-Fey I was just in the process of using @AndrasDeak's suggestion for my desired solution, but your solution works wonder, dpaste.com/ATW4UBP3K
 
What's the benefit of converting a config dict to instance attributes? I would just save the dict and use it directly instead of doing this shenanigans, any benefits or is this just cargo cult?
class Foo:
	def __init__(self, config):
		self.a = config["namespace1"]["a"]
		self.b = config["namespace1"]["b"]
		self.c = config["namespace2"]["c"]
		self.d = config["namespace2"]["d"]

	def do_stuff(self):
		if self.a:
			print("a")
		if self.b:
			print("b")
		if self.c:
			print("c")
		if self.d:
			print("d")
 
@CoreVisional Umm, you never even look at the return value of ask_yes_no_question though? Your code always behaves the same way, regardless of whether the user inputs "yes" or "no"
 
@Hakaishin It helps to make sure the config is correct.
 
1:57 PM
@MisterMiyagi how does it do that?
 
The config content gets validated when instantiating Foo, not an arbitrary time later when you ask Foo to do_stuff.
FWIW, I prefer __init__ to take a, b, c, d explicitly and have a separate from_config classmethod that does the unpacking.
Makes for easier unit testing and self-documenting code.
 
user13727121
@Aran-Fey I don't get it, it works fine for try_again function, I forgot to comment out user_choice. I've also changed no answer to exit() and put an else statement incase the user enters any input that are not yes or no
 
That's a bad idea. Why does an input of "no" automatically exit the whole program?
The function's responsibility is to return a boolean, not shutdown the program
 
Delegation!
 
user13727121
@Aran-Fey If user inputs yes, program will go on, otherwise, no means that they want to quit the game
 
2:04 PM
That's something to be decided by the function calling ask_yes_no_question, not by ask_yes_no_question itself.
 
@CoreVisional your function now handles all yes/no questions. "Hello, do you like the color blue? No -> exit()"
 
Otherwise, you cannot reuse ask_yes_no_question for any other y/n questions.
Like, say, "do you want to exit the program?"
 
user13727121
Oh I see what you meant by behaving the same way, returning False will just keep asking the user for number. I immediately changed no to exit() without knowing the behavioral of the code
 
user13727121
@MisterMiyagi That means I need another input to ask if the user wants to exit the program? Shouldn't it be clear that if the user inputs no, it means they don't want to retry which ultimately results in quitting the game
 
DON'T: call exit() in ask_yes_no_question
DO: call exit() after you call ask_yes_no_question
Is this clearer?
 
2:16 PM
if ask_yes_no_question("Abandon all program?"):
    exit()
 
if ask_yes_no_question('Lasciate ogni speranza?'):
 
Oh the joys of trying to get Flash running in TYOL 2021
Our migration schedule slipped by a month or three and it would be really nice to see what the pages used to do before we start writing new ones
I was able to get Flash working on my machine by downgrading firefox to December's release, but {coworker} isn't so lucky because his flash player got atomized by a windows update
Archive.org has a fine selection of old flash installers but who knows which of them have conveniently included a kill switch
 
user13727121
2:37 PM
@AndrasDeak Code: dpaste.com/CA5LQ975L, did I do it right now? I should probably call start_test instead of using continue, but both works, except that I don't want the same multiple calls in a function.
 
@Kevin shudder
 
He just got the scary gray rectangle saying "this plugin is vulnerable" which is a great improvement over the previous boring white rectangle of nothingness
 
2:55 PM
cbg
 
@CoreVisional I like continue better here. As you say, it's nice to call start_test just once.
 
3:06 PM
You could probably also replace that elif with an else so you don't have to ask the user if he wants to quit twice
So something like
def try_again():
    while True:
        start_test()
        if ask_yes_no_question("\n\nDo you want to retry? (Y/N): "):
            continue
        else:
            exit()
Additionally, as is often the case with loops that might execute continue as the last instruction in the block, you can refactor it to not use continue
def try_again():
    while True:
        start_test()
        if not ask_yes_no_question("\n\nDo you want to retry? (Y/N): "):
            exit() #or `return` or `break`
 
3:21 PM
... Since while True essentially always implicitly continues at the end of the block anyway
 
You can take the refactoring a step further and put the condition directly in the while:
def try_again():
    while not ask_yes_no_question("\n\nDo you want to retry? (Y/N): "):
        start_test()
@CoreVisional ^
 
But that will ask "retry?" before it calls start_test() the first time, so you would need an additional start_test call above the loop
Once again we are foiled by Python's lack of a do-while block
 
user13727121
3:36 PM
@Code-Apprentice I think it should be while ask_yes_no_question("\n\nDo you want to retry? (Y/N): "):, the not keyword asks the user for number even though the user responded no
 
Ah the classic "applied boolean negation too many times in your brain" problem... I'm never going to not fall for that as long as I don't not code
3
Good thing it's easy to test for
In the rare case where I need do-while like behavior, I prefer the return/break/exit approach over the call-start-test-twice approach. But they do the same thing so it's more a matter of style than functionality
 
@CoreVisional yes, you are right
@Kevin good point
def try_again():
    start_test()
    while not ask_yes_no_question("\n\nDo you want to retry? (Y/N): "):
        start_test()
 
user13727121
I looked up not keyword from the examples of yours and Code-Apprentice, had me confuse for a while, so I just put it in my brain like, if not ask_yes_no_question means if any of the answers that would return False, program would exit. I keep forgetting that excluding the not keyword means True
 
bleh...
@CoreVisional More accurately, the not keyword flips its operand. So False becomes True and True becomes False.
the confusion here is that my code is incorrect...remove the not when you put the condition in the while loop.
assuming that when the user types "Y", then ask_yes_no_question() returns True.
 
3:51 PM
If this helps, here's another way of looking at it
#this code:
if not some_expression_goes_here:
    whatever()

#is identical to:
if some_expression_goes_here:
    pass #in other words, do nothing
else:
    whatever()
 
user13727121
@Code-Apprentice I know, but I'm just confused of the not keyword in general
 
@CoreVisional Do you have any questions about it or anything we can help to clear it up?
One way to make the usage of not clear in the code is to use explicit variable names:
should_retry = ask_yes_no_question("\n\nDo you want to retry? (Y/N): ")
Now we can easily reason about not should_retry vs should_retry.
Of course, this relies on the name being accurate to its actual meaning.
 
If only you could do shouldn't_retry = not should_retry:, but alas, commas are allowedn't
 
nor apostrophes
 
Oops, that's what I meant
What are apostrophes if not commas doing a backflip
 
3:55 PM
and yah...my example isn't great
as far as English grammar is concerned
 
user13727121
@Kevin The way I receive it is
 
user13727121
if False:
    whatever()


if True:
    pass
else:
    whatever()
 
yes, those are the same
Usually the expression is not a literal True or False, though
 
user13727121
Alright, I think I get the idea now, whenever a not keyword is present in an If statement, it just means that if it's not this or that, do this
 
user13727121
@Code-Apprentice Yeah I know, it's just how my brain translates it to understand the concept
 
3:59 PM
I feel like I've seen users on here say "comma" when they meant "apostrophe" fairly frequently... I wonder if it's maybe a holdover from their native language where the terms are identical
They've influenced me with their ways and customs
Help I'm becoming more cultured
@CoreVisional btw, not can appear in any kind of expression, not just ones appearing in an if statement
x = not y is valid, for instance
It's versatile in terms of typing too, you can even do foobar = not 23 or print(not "Hello world!")
Although these are rather silly
 
user13727121
@Kevin good example, even though we can't name them like that, but I get the idea of it. Is it like assigning should_retry (True) to should_not_retry and make it false by using the not keyword? Or that I may have thought too much of this example
 
Your understanding is correct
 
user13727121
I grasp the not keyword concept easily when using it in conjunction with the in keyword, like in this example
 
user13727121
name = ["Dorothy", "Smith"]

if "John" not in name:
    print("John is not in the list")
else:
    print("John is in the list")
 
fun fact, if "John" not in name: is also valid syntax
 
user13727121
4:09 PM
edited If not "John" in name, I found that it confuses me sometimes
 
Strictly speaking the not operator and not in operator are distinct operators, but it's not too hard to see how they're related
Or, hmm, am I thinking of something else... One sec
Ok, I had it right, they have separate entries in the operator listing docs.python.org/3/reference/…
 
user13727121
@Kevin I don't think it is difficult to see the relation of it. I saw an example of an If statement using not in when I was still learning If-Elif-Else, I picked up the meaning of not in fairly quickly, I mean, it just makes sense, if it's not in there, we do something about it
 
The more interesting operator pair is is and is not, because x is not y has different behavior from x is (not y)
 
user13727121
@Kevin so far, I haven't used is not, but I can see that it's similar to not in, if it is not this or that, we do this.
 
Right
The is operator is quite uncommon so you don't need to worry much about how it works
Unless you're getting your hands dirty writing a data structure that cares a lot about memory addresses, it's not good for a whole lot
The one exception being: when comparing something to None, prefer x is None instead of x == None
That's useful even in non-dirty-hand scenarios
 
user13727121
4:18 PM
I'm gonna learn about the not keyword some more, seems useful, I mean, it already shorten the code in the solution you provided and still outputs the same result
 
Is it according to spec or just a weird CPython quirk that kwargs may contain keywords?
 
I will inspect the spec. Do you have an example?
 
>>> def bar(**kwargs):
...     print(kwargs)
>>> bar(**{"from": 1})
{'from': 1}
>>> bar(from=1)
...
SyntaxError: invalid syntax
 
I can't reproduce that ^
 
@CoreVisional yup. Simplifying like this often helps focus on the relevant aspects of the concept.
 
4:28 PM
oh yes, I can. I used a non-keyword in my first example.
 
docs.python.org/3/reference/expressions.html#calls talks at length about calling functions using kwargs, but it doesn't seem to have any restriction on keys
 
@Arne You had me worried there for a moment. D:
 
I mean
 
user13727121
@Kevin Oh nvm, I tried to use x is None in an example, didn't work, probably because of the kind of example I had
 
def bar(**kwargs):
    print(kwargs)
bar(**{"oh hi": 1})
 
user13727121
4:30 PM
while True:
    name = input("Your name:")
    if name is None:
        print("Name Required")
    else:
        print("Welcome, " + name)
        break
 
you can have valid dict keys which wouldnt be valid variable names by themselves
 
@ParitoshSingh Good point.
Alright, that's all the convincing I need. hurries back to castle MiyagiStein
 
wasn't there a pep at some point about introducing \class = 1 as valid syntax?
 
Arguably "Next, for each keyword argument, the identifier is used to determine the corresponding slot" implies that all keys of kwargs must be a legal identifier, but it's hardly spelled out explicitly
 
@Kevin took me a few minutes to figure out what TYOL meant
 
4:33 PM
@CoreVisional Yeah, I wouldn't expect that to work because input() doesn't return None under any circumstances. Even if the user presses Enter without typing anything, input() will return the empty string, "", which is not equal to None
 
even if I add the missing O duckduckgo struggles a bit
 
@AndrasDeak I meant it as "The Year of Our Lord" but Google tells me that the acronym has taken on other less savory meanings
 
I figured it out eventually
 
@Arne There was a PEP saying the type of a generator is ⚛, if that counts for anything. ;)
 
I didn't see any meanings for the acronym in duckduckgo
@Arne not sure if PEP, but definitely discussion
 
4:35 PM
I figured that you figured, but I may as well take this opportunity to make it clear which meaning I'm endorsing
I do love to be pointlessly unambiguous, it is known
I wonder if I could find the kwarg-slotting code in ceval.c... Or will the file pretzel-fy my brain like it often does
 
shudders
yeah, that was it
 
Never made it into a PEP, which can only mean that it's delayed until 3.11
 
petition to keep it delayed :P
what's the point of this change? i dont see any value proposition here
 
Here is where the **kwarg dict starts to gets upacked and put onto the stack. The only thing the code bothers to check is whether the keys are strings.
the type checking is pretty fast. Just some bit arithmetic. In comparison, validating that each key is a proper identifier would be glacial. Chalk it up to "we won't slow down function call efficiency in the normal case for the benefit of a corner case"
 
4:50 PM
that sounds fairly reasonable
 
@ParitoshSingh when among all the possible identifiers you really really really want to use a keyword. What's not to want?
 
I've occasionally wanted to use in and from as parameters
 
partial_sums = [total := total + v for \for in \in if \if]
(slightly reworked improved asspression PEP example)
I guess for \if in \for if \in would be even superior
 
[\:= := \:= + \+ for \for in \in if \if]?
 
5:05 PM
perfection.gif
And when they say "but := is not a valid identifier" we'll revolt
 
I have installed this package pypi.org/project/ipynb-py-convert, how can I run it through CMD line?
 
@entithat There are usage examples right there, have you seen those?
 
ipynb-py-convert examples/plot.py examples/plot.ipynb
yeah, but my packages folder is not in windows PATH
i don't even know where these packages are located
 
Use py -m ipynb_py_convert then
 
it says E:\pwr>python -m ipynb-py-convert
C:\Program Files\Python39\python.exe: No module named ipynb-py-convert
hm how to install them globally?
 
5:18 PM
of course there's no module named ipynb-py-convert, that's not a valid module name. How would you import that? If you run it with -m, it's ipynb_py_convert
 
oh really, did not notice. Thanks a lot
 
5:54 PM
Hello,
I am trying to iterate over a dataframe in jinja2 template.
i have a dictionary with a single key having multiple values.
Does anyone know how can I calculate sum?

My code:
{%- for index, values in df.iterrows() -%}
{{ values['CasesWorkedCount'] }} // Prints 30 and 40. I want to print 70 instead
{%- endfor -%}
 
6:23 PM
@LinuxUser probably values['CasesWorkedCount'].sum() with no loop...
 
@LinuxUser This is not front-end work. You want to groupby and sum() the df beforehand. You'd also probably want to convert the results into a nested list of python types
 
sorry, df[...].sum()
 
How can you save your progress when you have a merge conflict, and you've resolved some of the conflicts, but aren't completely finished yet? You can't commit, so... I guess you stash the changes?
Doesn't seem like it lets you stash either
 
6:39 PM
@ParitoshSingh the one use case I've seen was when APIs that included keys like "class" were translated from a language that allowed that name to python. The translators would then try to do RequestData.class, and apparently using class_ made them feel very bad.
 
@Aran-Fey after quite some searching I could only find stackoverflow.com/questions/34685407/…. Not sure how doing that would interact with your repo.
OK, the comment pointing to the example at git-scm.com/docs/git-worktree#_examples seems very relevant
probably not meant to keep both worktrees for long
 
Thanks. As usual, git's design decisions make zero sense to me
 
That was the only google (ddg) hit. Everybody else wants to know how to finalize merges or how to abort them. Based on this most people don't want to stash merges in progress.
I suspect merging is fragile enough that they don't want to support messing with the process.
 
@AndrasDeak @roganjosh Thank you.
 
7:12 PM
@Aran-Fey Someone much wiser than I suggested rerere. Perhaps it'll be of use to you?
 
> When your topic branch is long-lived, however, your topic branch would end up having many such "Merge from master" commits on it, which would unnecessarily clutter the development history. Readers of the Linux kernel mailing list may remember that Linus complained about such too frequent test merges when a subsystem maintainer asked to pull from a branch full of "useless merges".
I like the pop culture reference in the docs
@inspectorG4dget interesting tool, thanks
the name sounds like a bad joke
 
@AndrasDeak all credit goes to my friend scriptbae
 
I don't think that helps in my scenario, I haven't finished a merge that I could want to re-use
 
Hi
How to host some text on localhost?
import http.server as hp
import socketserver

PORT = 8000

Handler = hp.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(("", PORT), Handler)

print("Serving at port", PORT)
httpd.serve_forever()
I currently have this, but it shows directories on localhost.
 
ehm... I usually just use python -m http.server
 
7:20 PM
I want it to show some specific text
 
try adding an index.html to that root?
 
7:37 PM
Why wouldn't you use Flask, @BlackThunder?
Or FastAPI I guess if you don't need the actual web page
 
Hi guys, just out of curiosity what does top 1% mean in stackoverflow, is top 1% > top 20%. The doubt arises because on another website after being on the top, i saw it mentioned me as top 1%, so I got confused because I thought top 20% was greater than top 1% and so on..
 
Top 1% > top 20%
 
the top 20% of 100 is 80, the top 1% of 100 is 99
 
Yea that's true, silly meh. Thanks for clearing it :D
 
I don't know what heuristic SO uses to choose your benchmark, though
For example, whether it chooses to say "Top X% this month" vs. "Top Y% overall". They must have some reasoning over what gives you the biggest fuzzies
 
7:43 PM
Ah I see, I dont think its randomly showing months and weeks and overall either. I guess they check which is higher and then show it?
 
Seems like I was looking for Pyzmq
 
Okay I am still confused, what does it actually mean by top, certainly its different from normal 1% and 20%.
 
There is a pile of 100 people and you beat 99 of them, thus sitting on top of the pile
 
@CoolCloud do you know what percentiles are?
Not percents; percentiles.
 
7:56 PM
Hello
 
@roganjosh Oh that makes sense.
@AndrasDeak Nope, ill take a read there.
 
8:17 PM
@ParitoshSingh Yes, there was a discussion on python-dev about ten years ago as to whether dict keys should be checked for conformance with variable naming rules, and the devs decided that it wouldn't justify the effort.
 
ah yep, good. makes sense
 
8:54 PM
 
How are their arms not sheered off at the bottom of that!?
 
arms don't hold weight
 
9:36 PM
Guys. I want to write a genetic algorithm. Actually, I have already done it with python. But it's very slow. Will be it better if I will write it with javascript(node.js) for example? What can u tell about the speed of both?
 
how many flags can i use in an Enum.flag? or can i basically keep adding them? (I have about 30 possible flags)
 
10:17 PM
@entithat We can tell you nothing. Neither language is primed for solving combinatorial problems. I make them work in Python - is that any help?
There are plenty of libraries that will give you bindings to existing, compiled, solvers. Separately, I found out last week about Barnacle Mating Optimisation, for example
 
hm. there is not complicated methods, just simple function, loops and objects..
 
It's always the loops that will be the killer
 
@roganjosh pastebin.com/zHxBHJyB take a look
 
You can push a lot of stuff down into C, depending on how far you're willing to go in abstracting the problem into dicts and arrays
Well, I'm not going to review all of that, but you're using attributes, so you're stuck in python time
 
so I need to use lists instead of classes?
 
10:27 PM
Numpy arrays, not lists
 
hmm. Is there any need of them? I m not doing any math there. Just +- 1 to any element
 
BUT it takes thought. np.array is not a drop-in replacement to lists
@entithat Have you looked into SIMD, for example?
 
nope
 
To Google with you! :P
 
I have an idea to parallelize one loop
it could save me a few more seconds
 
10:30 PM
There are ways of accelerating things with numpy but it really does take thought for something like GA to get it right. You may have to reformulate the whole problem to be able to vectorize things
 
yes, I agree
ok, its already midnight here. Goodnight :) THanks
 
Goodnight
 

« first day (3806 days earlier)      last day (1158 days later) »