With the help of the 2x speed setting, I have created Dvorak Symphony no. 4 [Nightcore remix]. It's not bad, it's got a beat and you can dance (frantically) to it
I was about to say, now that your code has grown in complexity, it might be time to upload it to an external service such as pastebin or dpaste or gist
This has the bonus effect of not mangling the important whitespace of your code, and you don't even have to read through the code formatting guide tinyurl.com/urnzp7k
Eating code seems appropriate for a language named after a snake
I think I've mentioned before, that when I am trying to understand all the moving parts of some difficult code, I imagine that I am engulfing it as if I am an amoeba
Methodically disassembling each piece until only molecular nutrients remain and it becomes a part of me
@Félix If you can get into Indian music, check out Anoushka Shankar (sitar) & Patricia Kopatchinskaja (violin): Raga Piloo. It's just under 17 minutes.
@PeterBerrett I already linked you to our room rules and specifically mentioned post length. We also have a formatting guide. Please be sure to read these before your next post
[item in file2new for item in k] doesn't look right to me. Not much point in turning k into a set if you're just going to iterate over it. Set iteration is no faster than list iteration.
Without having any understanding whatsoever of what the final goal is, I'm going to say, try [item in k for item in file2new] instead, and see if that does anything
I agree that speed isn't the issue. My point is that speed is a symptom of the fact that somewhere along the line, some wires got crossed, and a variable got put into a position where it no longer serves the purpose that it was intended for when sets were suggested.
Have you verified that your example input gives exactly the True and False values you expect, in exactly the right position? Just looking at the shape of the results may not be sufficient
I'm unsure whether the programming language I tried to make (KevinScript) can be called "like" KevinScript. Is a thing like itself? It's a philosophical puzzle
In the UK, we have a petition system whereby, if you get over 100,000 signatures, it has to be debated in parliament. Will you accept UUIDs for a KevinScipt petition for dicts?
@Félix For a change of pace after that sublime masterpiece, here's a bluegrass band, Mile Twelve. Their fiddle player is Bronwyn Keith-Hynes. They're performing Elton John's Rocket Man.
@PM2Ring hah, nice timing, and change :) as a suggestion of my own, I'll take your "are you into indian music" and raise you an "can you get into japanese koto music"? it's a full album 50m but there are markers for the pieces! youtube.com/watch?v=zSkcW5w_L1o
@Kevin Making hash tables is fun. ;) It's not so hard to make a good one for a particular purpose (I've done it in C), but it's hard to make a good, efficient general-purpose one, like Python sets & dicts use.
Python's hash function isn't fantastic, but it doesn't need to be. They decided it was best to keep it simple & fast, rather than to sacrifice some speed for improved pseudo-randomness. But there have been some advancements in hash functions & pseudo-random number generation (both crypto & non-crypto) since Python's hash function was developed.
A posted a bunch of music links here a few weeks ago. Here's some from a couple of top mandolin players. Although they started out in country / bluegrass / Americana, their both rather versatile. And they both like playing Bach. In fact, Chris did a whole album of Bach violin pieces that he transcribed to mandolin.
A little bit of Bach on mandolin from Sierra Hull https://youtu.be/LSuUXQSMhrI Sierra with Chris Thile, showing off their superhuman speed & precision. https://youtu.be/DHznTAqc_3c
{relative} argued that Katy Perry is probably played more often than Koto instrumentals in Japan, so it was sufficiently authentic. I was not consoled by this.
Japanese guitar teacher, Maki Shizusawa, playing a little bit of blues, while wearing a kimono: youtu.be/33J15nBXVXw Some more blues from Maki, this time in Western clothing: youtu.be/33J15nBXVXw
My attitude towards Katy Perry in the general case is neutral-leaning-positive, so ultimately my total food experience was good anyway. Save room for the red bean paste fish-shaped cake.
I created a mental image of that place with zen little ponds and the sizzle and that sweet, perfectly cooked meats and now I kinda want to gril something.
I so wanted a zen little pond, maybe some water pouring through a little bamboo aqueduct thing, into a deer scare that goes clonk every fifteen seconds
It can do both: "[These fountains were originally intended to startle [...] deer [...], but shishi-odoshi are now [...] used primarily for their aesthetic value.](en.wikipedia.org/wiki/Shishi-odoshi)". Gotta have that aesthetic value for a proper sword fight.
Darn this finicky hyperlink markup syntax. Oh well, the link still works.
I have skimmed through JS' fetch documentation for twenty seconds, and my educated guess is that you can ask the web server to give you a reply with any encoding you like, and the web server might even oblige you.
I... think the resulting Request object's json method is smart enough to look at the requested encoding before trying to parse it?
@MisterMiyagi Well, sure. The only UTF size that doesn't need a BOM is UTF-8 (& UTF-7), but some genius at a company that shall remain nameless thought it'd be a Good Idea to give it one.
There's a small chance that the server is simply poorly configured and sent you utf32 without indicating that it is utf32 in the response header. But I find it more likely that fetch is just being stubborn
(with the caveat that my psychic predictions are not well calibrated for non-Python scenarios)
"The Unicode Standard neither requires nor recommends the use of the BOM for UTF-8, but warns that it may be encountered at the start of a file trans-coded from another encoding."
en.wikipedia.org/wiki/Byte_order_mark advocates for the UTF8 BOM a little bit. Programs have an easier time guessing the format of a file if a BOM is regularly present.
@MisterMiyagi The example given on the Wikipedia page is, old versions of IE can be susceptible to cross-site-scripting if you get tricky with UTF-7. Sounds more like a strike against IE than a strike against UTF7.
I know which one I would rather keep, and which one I want to lock in a safe and drop in the Mariana Trench
@Kevin That's true. The problem is that UTF-8 originally didn't have such a magic header, so by adding one, you're doing xkcd.com/927 Maybe it should have had one. Now UTF-8 is supposed to be compatible with Latin1, and it would've been easy to use a couple of invisible chars from Latin1 as a magic header. But there's this thing called CP-1252 which yams up that plan...
I actually did think of Olympus Mons before I submitted the previous message, but decided to keep things simple & not mention it. I should've known better. :)
I thought that you might have thought of it, so my Well Actually is more of a commentary on the difficulty of making meaningful measurements and specifications, than an earnest attempt to win pedantry points
In other words, I don't aspire to make anyone else look foolish, because it's more interesting to keep all the foolishness for myself
@Kevin That planet distance program I wrote recently could actually plot it. But I haven't played with that aspect of Horizons yet, so I haven't studied those parts of the docs. I know you can specify surface locations in terms of latitude & longitude on bodies that have a defined prime meridian. I think you can also use named locations in some cases. You can certainly use official observatory names on Earth.
Well, they weren't measuring interplanetary distances. But it was still pretty tricky, subtracting Earth motion from Mars, or whatever. Fortunately, Earth's orbit is pretty circular. The eccentricity is only ~0.0167
And we've got excellent records of the Sun's apparent orbit. The Babylonian Astronomical Diaries span ~7 centuries, and they formed the basis of Western astronomical data.
If you want a totally clean and hard restart, maybe you could do something with subprocess... Start a new Python instance and kill the existing one with exit()
But I wouldn't resort to subprocess unless I had a very clear idea of what state I'm trying to reset, or what resource I'm trying to free, and why a regular loop can't do it
I'd hate to try writing something like that. It'd be very painful to test it if you messed something up & it filled up your machine with stuff that keeps restarting itself when you try to kill it.
I experimented with subprocess.Popen(), os.execv() and a bash script already. But I may be overthinking this already, missing the forest for the trees while consumed by this coding frenzy.
There is a (another) spot here for a while loop that I did not try yet, so here we go...
Do you really need the script to restart itself? Why not just have a cron job that checks to see if your script's still running, and if it isn't, the cron job respawns it. That'd be easier, and more controllable.
@PM2Ring Yes. I run everything on a Google Cloud compute instance. The one time it was apparent that there was stuff restarting, I could at least just reboot the machine quickly.
@PM2Ring The script itself does not stop. But in certain cases (too many threads not having generated any output recently, not enough data being processed per minute, too many exceptions* occurring per minute etc.), I'd like to restart the script.
* that happens rarely, only after a long time or when using too many threads
So I'm just trying to get some new ideas here or at least stop myself from fixating on a particular approach.
I've been working on the data throughput limitations the last days, as far as the software is concerned. Talked to a Google Cloud sales rep today to increase the vCPU quota, since by default one can only use up to 8 vCPUs per geographic region (hence machine). So I should be able to upgrade the hardware soon.
And the few remaining exceptions that do occur on occasion or after quite some time has passed are not particularly straightforward to deal with (since this mix of threading, selenium, virtual display and authenticated proxies is a bit of a pain).
The script needs to process about 500k rows of a .csv file with ~10 columns. Once it's finished, it should stop.
TLDR: It's needlessly painful at the moment to get the script to run for, e.g., 24 hours with no checks whether things are still running fine.
If the Python program dies in case of <unwanted behaviour>, e.g. via ctrl+c, then I'd go for a shell loop.
NB: If you are already working with threads and don't need shared memory, then multiprocessing is a good alternative to scrub clean any stuck resources.
I have a question, after reading this: https://stackoverflow.com/questions/1132941/least-astonishment-and-the-mutable-default-argument?rq=1 Why aren't default parameter values for a function stored in its `.__dict__` if they hold state throughout all fucntion calls?
Can someone rewrite the 2 sections of code here web.archive.org/web/20200221224620/http://effbot.org/zone/… (under Valid Uses for mutable defaults) I have tried with the following, but dont get the abnormal behaviour the author alludes to in the first example
def hello(a,b,callback):
print(a,b)
callback()
for i in range(10):
def callback():
print("clicked button", i)
hello("ButtonObj", i, callback)
@Aran-Fey aran could you tell me, if you return a function as a first class object, is the function's header being executed again? (aka being redefined again)
Oh, I see, so each time I do out() it is running def foo().. again and when I do return foo it is obviously returning the new foo function created earlier