« first day (3345 days earlier)      last day (1828 days later) » 
00:00 - 20:0020:00 - 00:00

00:01
link badge tracker has gone crazy i.sstatic.net/jRHVi.png
I even got a silver badge of that kind
nevermind, they just fixed a bug meta.stackexchange.com/questions/340292/…
00:15
@roganjosh haha, I was having my after work liquid bread while typing that on my phone, my bad!
No apologies needed, I found it pretty funny :) It reminds me of Crab People
wim
wim
yeah I got 13 badges
just need 34 more to have a thousand
Huh, a quick glance at the star board of "it rubs me gently and lovingly" + "trough people". Is Buffalo Bill a new RO?
00:34
@wim maybe wolfram? Otherwise I wrote a simple HTML page with jsxgraph some time ago with a graph and controls just like you described.
 
5 hours later…
wim
wim
06:01
that was a great puzzle! 🤯
 
1 hour later…
07:10
cbg guys o/
07:36
cbg patch
was there a builtin method to set a max value for a numpy array
 
1 hour later…
08:51
@Skyler I don't believe there's any such property that can be set. That would probably be quite a bit of overhead
@roganjosh or at least an operation that clip to the max value
i mean you can do it by subtracting an element-wise modulus
but i was wondering if this was baked into numpy
Or just by using np.where
arr = np.where(arr > max_val, max_val, arr)
I'm not sure why you'd use modulus but maybe I'm missing something
well like lets say you wanted the max value to of matrix M to be 255. You can do M - M%255
Can I infer from that that you're talking about RGB?
in this case yea
08:57
It's possible that image-processing libraries will do this for you in a wrapper around numpy but the problem is trivially solved with my where example
yea, im curious how the performance difference between M- M%255 and np.where would be actually
since you do have to run a comparison on each element to then execute your reassignment
It's vectorized
with numpy I just thought that vectorization means that it loops in execute time to remove the python overhead
It does, but it can also load single instruction sets into the CPU and push multiple values through at the same time
How would your approach not do that?
oh thats pretty cool, didnt know that
so basically np.where in this case would load a single instruction set that does comparisons on values and either passes or reassigns. The method I described would likely load a single instruction for the modulus, but then it wouldnt do that for the subtraction (or if it did it has to feed pairs of values instead of single ones)
09:05
Well, are you going to time it or am I? What's your approach, as code?
The only way I can think of doing it involves the creation of a temporary array of M%255
So that's even more work, but maybe you know a different trick that I don't
Also, 10000 - 10000 % 255 fails totally
yea, the mod makes a binary filter for values less then 510 and then gives multiples of 255 after that
My own point is moot about the temporary array because I guess it's no different than what np.where also does
the only thing annoying about np.where is that it flattens the array
arr = np.array([[10, 5, 2], [5, 10, 4]])

arr[arr > 7] = 7

arr
Out[16]:
array([[7, 5, 2],
       [5, 7, 4]])
np.where was overkill. Sorry, I've just woken up and full of a cold. Brain not in gear :P
actually, funny thing, I just kind of mindlessly typed arr into a cell on a jupyter notebook i was working in
and i had actually defined arr in another cell so i was calling that when i tried your code
ignore what i said about np.array
09:23
i have a model that has a property function based on another model. i can display the values in the django-admin using the list_display variable by passing the function name as an argument. I don't how to sort these values. I tried using the ordering variable, get_ordering_by function but all these take only the DataBase fields.
09:39
stackoverflow.com/q/59319106/4799172 needs more focus. They aren't even using the library they're asking about
09:53
^ closed. Thanks :)
> My username is bobby and password is tables' OR username = 'admin
This is why we can't have nice things
Depends what you mean by nice things. I'd say we already have a nice thing in SQL to get around this issue, it's just that 80% of people don't care to use it
Or, at least, that's my squinty-eyed-guesstimate based on SO questions
Which one you would choose? mongodb or MySql?
My TL was saying MongoDB is good for dumping data for statistics or to store configuration related data; for anything else go with SQL
There's just no way to make a call on SQL/NoSQL without knowing the problem properly
10:08
With MongoDB putting restriction on number of columns is little bit difficult.
MongoDB doesn't really have columns
Yeah it has fields
What does "dumping data for statistics" mean? What kind of data?
And that can be modified as in more fields can be added
@roganjosh like ongoing activities within a company like number of code submission in a day or number of bugs logged/closed in a day and so on..
Ok, so a document per day. Why do you need a limit on "columns" (and I'm still using that term because it showed you're naturally thinking in terms of a table, which partially made the decision for you)
10:15
@roganjosh Please read top 5-6 messages here : chat.stackoverflow.com/…
Wouldn't the date suffice as a key?
@roganjosh But would that be good choice for a key?
Based on your problem description that mentioned "per day" several times, it would seem like the answer is yes
No No! Not for that.
It's for a different project.
Dec 4 at 13:59, by TheLittleNaruto
It's gonna be a songs streaming application.
If the premise is that you want to keep a list of all the songs that a user listened to, then that doesn't make sense in Mongo (IMO) because the document would just be a collection of the same "stuff". A document makes sense if it's a collection of unrelated things that relate to a single person (in this case)
10:24
recbg
In any case, I think it's something you should talk to your TL about in more detail if you're struggling; it's too big a decision for us to make without knowing the problem properly, and it's also not really related to Python
Yeah! Right, Thanks for your above suggestions though
@AnttiHaapala nice hat :)
@Abhyudai for gold badges. I do not know why but all of sudden I got dozens of link-sharing badges...
137
Q: Why was I just awarded a bunch of "Announcer" badges?

ruffinI just got a notification that I have been awarded a bunch of "Announcer" badges. I'm pretty sure I didn't just have 25 people hit all of these shared links, if I even shared them at all. Below is a screenshot of my inbox. Note the scroll bar depth and the number of sites. These are all from today—

well...
I wasn't expecting somebody would comment on one of my oldest answer post: stackoverflow.com/questions/25460854/…
Now I updated my answer with two possible solutions.
Wondering if that would award me any secret hats?
11:13
@aadibajpai I decided to trace this back in my answer which might be of interest to you re: Flask development server. That gives you some idea of the extra layer that Flask adds over the server it actually uses
11:39
Lol, jason is a tag
How does that even get created? I assume this doesn't have to go through the whole burnination process? I could make the edits myself but then what; Still a meta post?
hi, has anyone used youtube api for uploading videos? It keeps asking me to do a manual authorisation but i need this to run automatically. I did 1 initial manual authorisation myself but it continues to ask for authorisation
...did you save the access token you got? And use it?
12:01
@Skyler surpisingly, np.clip, cc @roganjosh
or even arr.clip, it's a ufunc
TIL, thanks. I should really have checked the docs but I started out with np.where, which is a good indication of how my brain works in mornings :P
np.where is practically never the answer
Sure, I went on to correct myself as a couple more brain cells fired up
i managed to upload the access token to the remote machine and it worked - does that access token expire? (the uploader.py-oauth2.json)
don't know about Youtube specifically, but most access tokens do
12:21
is it possible to use the api without accsess tokens?
hi there
Hello
12:37
@ThelurkerLurker don't know. If it is, only a very limited part of it, probably.
13:12
2.7 had a builtin function, cmp, which is no longer a builtin in 3.X. Was it moved to another module, or is it just gone? I don't see it in my search results, at a glance.
Just straight-up gone, eh? Ah well, I can make my own in four lines.
There are suggested one-liner replacements in that link
cmp = lambda a,b: [[-1, 1][a>b], 0][a==b]
Readable and well designed ( Í¡° ͜ʖ Í¡°)
I thought I was the only one to commit the named-lambda offenses
I write them every once in a while if the alternative would be writing a function inside a function
Not that nested functions are an antipattern necessarily, I just don't want to overflow the mental stack of my reader
13:47
@Kevin cmp = lambda a,b: (a==b)-1 and (a>b)*2-1 is clearly superior
This is the substitute that I've seen published elsewhere, dates back to the dawn of C programming time: cmp = lambda a, b: (a > b) - (a < b)
(I found it in my copy of "Graphics Gems")
Huh! Clever!
And it is also listed in that link
...programming is ruining the word "clever" for me. It's never clear whether it's a good or bad thing anymore
Yeah. You've got to evaluate it in context. Is a knife good or bad? Well, are you cutting carrots, or the brake lines of your annoying neighbor's car?
13:57
cbg
And of course those are bad (carrots are gross) and good (your neighbor has become much nicer now that you've helped him win ten games of chicken against the gang down at Breakneck Flats) respectively
Before I waste a lot of time, is there a way to create a defaultdict using a comprehension?
I want to say "yes", because other than the first argument, defaultdict takes the same arguments as dict(), and you can pass a dict comprehension to dict()
>>> import collections
>>> d = collections.defaultdict(int, {i: i*2 for i in range(10)})
>>> d[3]
6
>>> d[100]
0
I'm not completely sure I've understood your requirements though
If the question is "can I hijack the behavior of dict comprehension literals to make {i: i*2 for i in range(10)} return a defaultdict directly, without me having to ever call defaultdict?", no
14:15
Yeah, I was trying to pass the comprehension without the dict brackets rolls eyes. It is Friday.
Carrots are inedible in all possible configurations, and the composition of the puddle of brake fluid and/or carrot juice in your neighbor's driveway has no bearing on his performance down at Breakneck Flats. Any cutting order is therefore acceptable.
Sometimes in the twilight hours, I have half-conscious dreams where I am presented a problem that writhes and changes as I examine it, making it unsolvable. I can get no rest until I realize that I am disconnected from reality, and I 1) give myself permission to leave the problem unsolved, or 2) pull out a thermonuclear device and obliterate the problem along with everything else within a ten mile radius.
Perhaps a similar strategy will free you from the knife carrot brake conundrum. I have activated the device. The knife, the carrot, your neighbor's car, your neighbor, and breakneck flats are now dust.
Breakneck flats was already dust, mostly, but now it's more of a crater shape than a flat
user11867329
Say something light
user11867329
to switch the vibe
14:30
Pandas have an extra thumb that helps them grasp bamboo more effectively
Sadly it doesn't make them better programmers
Giraffes fight one another by flailing their heads at one another. Crows remember your face if you do something nice for them. A pair of nearly-extinct rhinos successfully produced offspring recently.
Or maybe they need a better keyboard. That'd be one hell of an ergonomic keyboard
Whenever I see a headline like "last two members of an endangered species mate -- could they avoid extinction?", I am confused, because isn't the answer definitely "no"? Now all the members of the species are directly related to one another, and that can't be good for the gene pool.
Or is it, like, only 75% of offspring will be unviable, so the living members just need to quadruple their efforts to achieve stability?
The platypus is currently at "near threatened" which the second healthiest classification. For that reason, I don't think they were critically endangered in 2002.
Take some of the rhino offspring and irradiate them to shake the gene pool up a bit
14:41
Umm... got an announcer badge for sharing a post Martijn answered... I wonder when and where I did that :)
Well, it probably isnt going to help with them producing viable offspring but it's a short-term solution until we have something better
user11867329
I like your approach
user11867329
make it or break it wtv
I have an image of a rhino stood on a slowly revolving plate in a giant microwave, but alas, microwaves are non-ionising
en.wikipedia.org/wiki/Minimum_viable_population#Extinction says that, although it varies between species, 50 individuals is the benchmark for preventing inbreeding depression, and 500 is the benchmark for preventing genetic drift.
14:46
Morning cbg all
So, to everyone living in an apocalypse drama novel who says "look like it's up to us to repopulate the species", here's your reality check
"Looks like it's up to us, and the 498 other adults in our ragtag gang, to repopulate the species", is less effective of a pickup line, admittedly
"Not everyone can mate with George Clooney over there, so, as repulsive as I might be, someone has to do it with me." is only marginally better.
@roganjosh Apparently it was trendy in the 50s to bury a little nugget of uranium in your garden in the hopes that nearby plants would get a beneficial mutation. So it's not a totally crazy idea.
Then again, it was also once trendy to drink radioactive water, so.
@Kevin Ok, I'm going to need a source for this. Where exactly was one supposed to get this uranium from anyway?
I'm looking for a source for the specific claim of regular citizens doing this, but here's a more general article: en.wikipedia.org/wiki/Atomic_gardening
user11867329
14:53
@Kevin Jesus... Are the mutated species ... "Patent-able"?
user11867329
'Cause I might wild out a bit on Lady Luck.
Hmm. Maybe I misread the claim when I first came upon it. The article linked above describes how trained experts would place a radiation source in the center of a five acre plot, and harvest the seeds of the plants that didn't die. Regular people could acquire those seeds and plant them in ordinary soil. So maybe there weren't any suburban gardens built around uranium nuggets.
@OakDev I suspect yes. en.wikipedia.org/wiki/… doesn't appear to have any restrictions based on how you developed the mutation, only that it doesn't occur naturally
Hello All,

i new to python and have created a slack bot in it

https://pastebin.com/LjHc4gfB

There are 2 problem in this one:

i'm trying to do it in multithreaded manner as it should be able to handle multiple request at the same time but unable to make it in that manner
the another thing is when it posts the message in slack it takes that message as the input
For example: if user input ip address
it output its details (which it should do)
but it takes that output as the input (which it should not do) and that cycle goes on and on
I think the conventional solution to "how do I get my bot to stop responding to itself?" is to put a line like if message.sender == me: return in your def a_message_appeared(message) function
15:09
well if i create that function then how am i going to stop it..
will stopping that thread will be sufficient..or is there any other way i can stop it
I suspect you have already created that function: def query(**payload):. It's decorated with @slack.RTMClient.run_on(event='message'), and I assume that means "call this function every time a message appears"
A simple return should be sufficient to stop it.
i tried that but it is not working
yes
i put return in slack_post
If you're saying "I put return, and nothing else, at the end of slack_post", then that won't do much, since all Python functions effectively have an invisible return at the end anyway.
You need to return at the top of the function, but only when the message sender is the bot. I don't know exactly how you determine this with the slack API.
well i can determine in the slack whether it is a bot or not ....
so what i understood is that in the query() function, i have to determine whether it is a bot or not,
if it is a bot i have to create a function with only return statement...??? but you said that every function has return in the end ..
so how can i close that
I'm not sure what you mean by "create a function with only return statement". Just return from the function you're in.
@slack.RTMClient.run_on(event='message')
def query(**payload):
    if payload["type"] == "bot_message":
        return
    global data
    data = payload['data']
    global web_client
    web_client = payload['web_client']
    #await asyncio.gather(db_conn)
    db_conn()
Something like this.
15:21
ok.. got it
Thanks
one more thing if the loop gets over then the number of threads will also get decreased??
I don't know enough about async to answer that with any certainty. Once you get things mostly working, you can experiment a little and see how many threads you've got
Guys, I get this in Pycharm: python import resolves to its containing file
I cannot call directly with module name..
hi everyone I'm new here does anyone know about audio and speech recognition I'm trying to recognise phonemes in audio like in spare if anyones heard of that
sopare
@MikaelKen I think it's trying to tell you "don't call your files the same name as the packages you're importing"
aa
but i get now: 'module' is not callable
TypeError: 'module' object is not callable
15:25
If you're doing import thing followed by thing(23), then certainly you're going to get that error
Perhaps you've got a function with the same name as the file it's in? In that case, try import thing followed by thing.thing(23)
This is a fairly common "Gotcha". Even the builtin modules are not free from it: the datetime module contains the type datetime
Apparently I just had to import same module name from the module...
The creator of my module only gives console examples
As in, from thing import thing? Yeah, that will do it too.
@michaelspencer Hmm, can't say that I do. I see that sopare is open source, so perhaps you can poke around their repository and get an idea of how things work.
the files are uncommented and I can't track it through the process I can record audio set a volume break into pieces and array it what I'm not sure about is how to compare file chunks when I google all I get is the speech recognition module probs I want to do offline
I have a single b phoneme so when I speak into mike want to see if that single phoneme is in what I said
15:35
I understand your frustration. I rate the difficulty of this project at 8 out of 10. 9 if you want it to work as well as commercially available products.
What would a 10/10 difficulty be?
I had the same question...
my theory is instead of hours and hours of audio I was thinking along the basis of audio for the 40 phonemes in English language sphinx is ok but there's no uk eng for it its us english
Win a Fields medal, disrupt Facebook's monopoly on social media, create a self-improving AI
hmm, yeah, those do sound pretty dang difficult
15:37
Tip: do the third one, and ask it to do the first two for you.
Always fun when you're trying to understand some code and the most creative variable names are used...
if ('shift' in characteristic):
    ssim, ssl, ssr = self.token_sim(characteristic['shift'], dcharacteristic)
    if (ssim > sim):
        ssim = sim
    if  (ssr < sr):
        sr = ssr
    if (ssl < sl):
        sl = ssl
token_sim[0] += sim
token_sim[1] += sl
token_sim[2] += sr
understandable if you assume 'left', 'right', but why not just make it more coherent...
everybody loves a puzzle, right?
has anyone used spare before
sopare
15:55
I think if anyone had, they would have chimed in a page ago ;-)
@michaelspencer heads-up: you can edit/delete messages for 2 minutes in chat :)
does anyone know about speech recognition in general or about audio comparisons in python
I think this problem is sufficiently hard that even if someone has used sopare and gained an intimate familiarity with it, if you asked them "can you explain to me how it works?", they would reply "certainly -- but first you need to read these introductory textbooks on markov models, neural networks, signal processing, human biology, and particle physics"
You won't find a nice tutorial laying out everything you need to get from square one to done, because that tutorial would have the equivalent information of half a dozen college courses
16:02
I know how it works I just can't work out a way to compare the arrays within a range or % comparison
Compare what arrays?
That's the "draw the rest of the owl" part of the problem :-)
@KieranMoynihan I'm guessing it's a comparison of "the array containing the waveform data of the user speaking into the mic just now" against "the array of the waveform data of me speaking the phoneme 'buh' that I recorded when I was training the program"
audio convert to np arrays I have a single phoneme with is 2000 numbers long need comparison to see if the pattern is within another longer audio file say 20000 numbers long a bit like if text in text but I need a range or a way of standardising the audio files to compare a % array as in
On another note, is it best practice to always nest functions into a parent function if they are only ever going to be called from that parent function?
16:07
I bet that... [I throw a dart at my board of "cool math stuff I don't understand"]... Fourier transforms would be useful here
Not without wavelets or something, probably...
@KieranMoynihan Perhaps, if you're really very confident that the function will never be useful anywhere else. But if there's any doubt, it may be sensible not to nest them.
the problem is that it's non-trivial to tell "the frequency of the sound NOW" because computing a Fourier transform is inherently non-local (non-"NOW"-like)
perhaps just taking a narrow window is enough to say something about the frequencies, not sure...never worked with things like this
I am learning slowly but sound is a weird thing to get head around
@Kevin In general, I don't nest most functions that fit that case very often, simply because I don't like how it changes the function structure so much.
def function_a():
    def function_b():
        pass
    def function_c():
        pass
    def function_d():
        pass

    # do stuff
    function_b()
    function_c()
    function_d()
If I wanted to look at what function_a does, I need to first look down to the bottom of function_a, then move back up to the top of function_a to see the other functions within.
Doesn't sit well with top-to-bottom reading, at least for me
16:13
Mm hmm. You're giving up linearity, so there's got to be a compelling reason to do so anyway, such as "clarity is substantially improved, even accounting for a more convoluted control flow"
when I do that I usually define the nested function right before use
Depends on the length and quantity of the functions for me. Sometimes it's easier to understand if you define them all first and then call them one after another
@Kevin it improves the clarity of function_a by calling some function do_x_thing(), rather than 100 lines which aggregate to the same do_x_thing()
Though I don't really see much advantage to keeping the functions nested, when it could be shifted (say) somewhere else outside function_a, to keep the linearity of function_a.
A handful of my animation projects have a function logical_to_screen, which converts a point in the range of [left=0, top=1, right=1, bottom=0] to the range of [left=0, top=0, right=width_of_result_image, bottom=height_of_result_image]. The math for this conversion is simple arithmetic, but it's like forty characters of simple arithmetic. And I often need to do the conversion for every single "draw point" and "draw line" and "draw rectangle" operation I'm doing.
I could inline the math half a dozen times in my render() function, but readability suffers. And it doesn't make a whole lot of sense to make logical_to_screen a global function, because width_of_result_image and height_of_result_image are local to render().
Defining logical_to_screen in the global scope and changing its parameter list from p to p, width_of_result_image, height_of_result_image is a valid design, but it's also a tradeoff to readability. Sometimes I do it, sometimes I don't.
I think access to parent's local vars is probably the key point of decision for me.
16:24
Mm hmm, that is often a deciding factor for me.
programming is not an exact science... and yet everyone does it wrong ;P
user11867329
@Aran-Fey What's an ego anyways
@OakDev I do believe it's what you have in spades...
user11867329
@KieranMoynihan "He then said, to a stranger on the internet"
@OakDev What is that even supposed to mean? I'm only judging the person you present yourself as on the internet, not the person behind the screen. It's not who you are underneath, but what you do that defines you.
16:34
Without the third great virtue, we are nothing
17:00
@Kevin We turned out alright, as a species, ... sort of
debatable
Details, details...
user11867329
@KieranMoynihan I'm not even sure of basic stuff like that anymore, too much adderall, not enough proteins, losing it.
@KieranMoynihan please don't encourage OakDev's off-topic asides.
@OakDev request as a room owner: please stop making noise again. It's alright if you go away until you feel better.
@AndrasDeak I wouldn't have described my comments as "encouraging [him]", but I take your point.
17:12
I just meant "not ignoring". Thanks.
user11867329
I still firmly believe the script for the CSV/XML thing was misjudged due to my reputation.
It would be beneficial to the community.

Stopping noise for a while.
thank you
Does anyone have a recommendation on preparing GraphQL queries? I'm currently using string formatting but it looks like this approach is going to be too brittle in the long run.
wim
wim
@Kevin I tried to use it for the paddle/ball game. Settled on a nested ternary (...quinary?)
-1 if b<p else 0 if b==p else 1
@wim If you care about this sort of this, the quinary should be ordered from most to least likely to occur
and since (assuming the structure of the paddle/ball game) p would be lower than b most of the time, it should be 1 if b>p else -1 if b<p else 0
by the way, my tests put it at about 0.03 usec difference per step in the quinary... that's real savings!
(where exiting the quinary on step 1 is ~0.053 usec and on step 3 is ~0.108 usec)
17:48
@KieranMoynihan How often does function_a get called? Those nested function definitions get executed every time you call function_a.
@PM2Ring The overhead is not huge unless you're looping over it many times in a tight loop. The function object just has to be assigned each time, but the code object is constant. I only call function_a once in my particular case, anyways.
18:04
@KieranMoynihan Well, if you only call function_a once, then it's a non-issue. ;) I often nest helper functions in the __init__ of my main GUI class (which only gets instantiated once).
I'm pretty sure that nested function definitions get recompiled from scratch every time the outer function gets called. But I might be wrong...
wim
wim
@KieranMoynihan No, I do not care about micro optimizations. And that one is not even 1/30th of a micro optimization
wondering if it's possible to make an async itertools.tee concurrent without knowing some async synchronisation primitive. My initial guess was "nah", then "yah", now "nooo" again. Any tackers for "yay"?
@wim very clever...
@KieranMoynihan Thanks. I assume rhettinger knows what he's talking about. :)
18:20
@AnttiHaapala okay I changed it. I personally don't like both solutions, but I'm far away from Python these days, so I trust your opinion. — chuwy 1 hour ago
@wim ^
18:34
@wim so nanooptimization
You can't spell nanooptimization without "no op". My train of thought has derailed.
@wim there's some irony in packaging being held back by packaging...
18:50
@Code-Apprentice "As a professional python program, I don't worry about how the code is translated into assembly language or CPU instructions." I've just outed you as a bot!
West coast cabbages, folks!
it's quite interesting... before my morning greeting, I thought "I really should update room6 about where I am", and I then remembered a previous comment about how none of us have actually ever met f2f before. It's truly a mark of this community that we foster such close relationships without even knowing most people's names (except for maybe their usernames)
wim
wim
That second comment though .... I can not believe this timing was a coincidence
@inspectorG4dget not to be contrary, but I've met several of the regular users in here f2f
@wim I guess I was just biased by my experience. But also "Heyyy! what the tomatos, man? When are we going to share many tavern cabbages?"
I feel like I should attach my profile pic and sharpie in my SO username next time I go to pycon
@wim nice
wim
wim
19:08
My visualization for AoC last night (spoilers maybe) reddit.com/r/adventofcode/comments/ea0lcv/…
I want to try out Nix for Python, anyone doing it currently? Any tuts to recommend?
@wim though the last two comments were a big letdown :D
wim
wim
> Consider other tools such as pip when pipenv does not meet your use case.
knifey spoony ??
No mention of poetry on that page nor here packaging.python.org/key_projects
@wim hope you're aware of the legacy of Breakout :P
@wim or pip-tools... :D
wim
wim
19:17
@AnttiHaapala huh, true
what's up with this guide and why are they so in love with a stillborn project
@AndrasDeak of course! But that's what everyone else did :P
#pypa @freenode
@AndrasDeak breakout, isn't that like some bad Arkanoid clone ;)
that brings memories
is there some efficient way to remove an item from a list based on identity, not equality?
@MisterMiyagi not really, iterate and remove with is
wim
wim
"do as I say, not as I do.."
19:28
I'm a little stuck on today's part 2: view spoiler
Arn
Arn
Hi, can someone tell me what is wrong with my answer as-is? I am not asking for votes, I just want dig deeper into the subject.
@AnttiHaapala yeah but I figured I'd use a more recognizable name
@Arn The answer to that was also given in the same thread, in the comments to this answer
Arn
Arn
@roganjosh could you be more specific as to what is incorrect?
I read through these comments twice
@Arn looks good to me, albeit the "the reference to a" part may be misunderstood. I'm guessing most downvotes are from before you edited your post.
19:32
I didn't weigh-in on voting on that question, but I guess it doesn't address GC
note that None by itself does not take any more memory, regardless how often it is named.
wim
wim
@roganjosh It doesn't need to address GC
None will never be collected
"whereas del annihilates an object and prevents it from existing in the name space" definitely isn't correct, though, which is what you originally said
@wim "Are those identical to each other if I use the manual garbage collection?" was the question
wim
wim
what is "manual garbage collection"?
Arn
Arn
@roganjosh I have removed that part.
19:34
gc.some_method_i_cant_remember()
wim
wim
maybe the OP thinks del name is a manual garbage collection, and doesn't realise this is just decreasing ref count
IIRC refs on None are not even counted.
gc.collect()
gc doesn't bother with reference counting, it bothers with reference cycles
Arn
Arn
Is there a part in the docs where I could read more on this subject?
wim
wim
nobody is talking about gc except for juanpa.arrivillaga, for unknown reasons (it has zero relevance to this question since there are no reference cycles here)
but anyway @Am , your answer looks ok to me.
Arn
Arn
19:38
Ok, thanks
When I first started with python, I attributed a lot of spurious issues with things not being garbage-collected. In the past, I really did do gc.collect() thinking that I could clear things away, and I knew yam-all about reference cycles when doing it
wim
wim
I would not worry too much about juanpa.arrivillaga's comments, he is not exactly the A-team
So I don't think it's unreasonable to assume that "manual garbage collection" might refer to gc.collect() but it should be clarified first
Jul 2 '18 at 13:55, by Andras Deak
>>> refcnt = ctypes.c_long.from_address(id(None))
>>> refcnt
c_long(4683)
>>> refcnt.value
4683
>>> refcnt.value += 1
>>> sys.getrefcount(None)
4685
>>> refcnt.value += 1
>>> sys.getrefcount(None)
4686
>>> refcnt.value += 1
>>> sys.getrefcount(None)
4687
>>> refcnt.value *= 0
Fatal Python error: deallocating None

Current thread 0x00007fe7d13da080 (most recent call first):
  File "<stdin>", line 1 in <module>
Aborted
@AndrasDeak nice:P
19:46
another time I deallocated 7, but that was by accident :)
@wim that's incorrecto, unfortunately.
and that also makes gilectomy so hard..
wim
wim
whoah
>>> import gc
>>> len(gc.get_referrers(None))
485
^ vanilla repl. In IPython :
>>> len(gc.get_referrers(None))
10932
much ado about nothing!
not bad (terrible)
00:00 - 20:0020:00 - 00:00

« first day (3345 days earlier)      last day (1828 days later) »