« first day (2971 days earlier)      last day (2202 days later) » 

00:01
@wim I don't remember what comment of yours I was replying to, but it's since disappeared.
00:15
I think I'm overcomplicating AoC day 2 part 2, but I think I now want to overcomplicate it
Rob
Rob
I did it in C#... which has a .IntersectsWith function built-in. And I still got it wrong on the first attempt :(
I want to see if I can do it in O(n) instead of O(n!)
00:49
Question, mysql is requiring python 3.7 64bit. But I can only find the 32bit version?
 
2 hours later…
02:39
do multiprocessing pools share global memory?
03:04
no
03:15
@KevinMGranger my solution is O(n^2) but in this special case where they are only one letter apart and there is only one such pair, we can sort first then O(n) search adjacent pairs. That gives us O(nlogn)
 
2 hours later…
05:40
cbg
05:56
What does "cbg" mean?
It means cabbage sopython.com/salad
Thanks, didn't know this existed :)
and obviously, didn't read the description.
06:13
cbg
Mile high cbg
Great cabbage in the sky?
@piRSquared O(l*n) is possible
@IljaEverilä aoc
06:49
IIRC I learned about Counter during AoC 2016
07:14
@Code-Apprentice ofc! that should be an automation given the format.
07:33
hmm is there any python interpreter with the assignment expressions already working?
I'll probably sound really stupid saying this but does cython count?
wim
wim
@AnttiHaapala you want to use that garbage??
@wim yes, for aoc :D
there are those parsing things that could benefit
08:21
@AnttiHaapala Oooh, smart.
09:02
recbg
09:24
cbg
today's AoC devolved into a really ugly chain of hacks for me
in the end it came down to "if this doesn't work out on the first try, I'll have to rewrite it from scratch"
but luck was on my side =D
    def integrate(a, b, interval):
        area = 0.0
        while (a < b):
            area += float(f(a)*interval)
            a+=interval

        return area

 why does this integral function give wrong value,
done? :P
@GustafLinder define "wrong"
also, a float is not of infinite precision
you should choose the interval so that
it is at least equal to the precision at both a and b
furthermore the cast to float seems unnecessary anyway...
unless your function returns Decimal.
still waiting for that "done" :P
@Arne you got a repo?
10:18
I do, but was too ashamed to upload yet
@AnttiHaapala I tested with a smaller interval and it returned the right value, or more exact so to say. Why is that
You'll have to be more specific. Function, a, b, interval. Use something you can integrate by hand.
ahh sorry, my fault
def f(x):
    return float(x**x)

def integrate(a, b, interval):
    area = 0.0
    while (a < b):
        area += float(f(a)*interval)
        a+=interval

    return area


print(integrate(1.0, 3.0, 0.5)) # Gives more exact
print(integrate(1.0, 3.0, 0.00001)) # Far away from exact
those float calls really are completely pointless
10:27
In [4]: def f(x):
   ...:     return float(x**2)
   ...:
   ...: def integrate(a, b, interval):
   ...:     area = 0.0
   ...:     while (a < b):
   ...:         area += float(f(a)*interval)
   ...:         a+=interval
   ...:
   ...:     return area
   ...:
   ...:
   ...: print(integrate(1.0, 3.0, 0.5)) # Gives more exact
   ...: print(integrate(1.0, 3.0, 0.00001)) # Far away from exact
   ...: print(3**3/3 - 1**3/3)
   ...:
   ...:
6.75
8.666626666761239
8.666666666666666
as I said, try something you know the answer to
@AnttiHaapala sleepy_guards <-- AoC spoiler
ohh, sorry. Thanks for the help! I checked my output to the wrong answer
@AnttiHaapala completely agree =D
just noticed that that innermost for is unnecessary. dd.update ftw.
10:56
Todays puzzle, in the way I did it, would have been a lot easier with numpy.
And thus, another mark on the "you should learn numpy" block.
Maybe I'll make that this new year's resolution..
11:54
cbg all
I have a simple (probably) for loop question
I have some code that is selecting a range of cells in Excel using openpyxl
It copies them into a list
at the moment I have to hardcode the start and end rows for each range
I want to loop it so that it selects 1-5,6-10,11-15 and so on
how can I do that?
If I understand correctly, you want your loop to iterate over 5 numbers at a time? Like this?
>>> itr = itertools.count(1)
>>> while True:
...     slice = itertools.islice(itr, 5)
...     print(*slice)
...
1 2 3 4 5
6 7 8 9 10
12:20
yes, I want to grab rows 1-5, put them in a list, grab 6-10, put them in the list and so on
@Aran-Fey
>>> itr = itertools.count(1)
>>> for _ in range(number_of_5_chunks):
...     for i in itertools.islice(itr, 5):
...         your_list.append(cell[i])
Alternatively:
>>> for chunk_nr in range(number_of_5_chunks):
...     for i in range(chunk_nr*5, (chunk_nr+1)*5):
...         your_list.append(cell[i+1])
You might not even need the list. Depends on what you want to do with it
I think I've done it with a while loop
while i < 250:
selectedRange = copyRange(1,i,5,i+4, sheet)
print(selectedRange)
questions.append(selectedRange)
i = i+5
basically I have spreadsheet with questions, consisting of a title row and 4 answers under each one on their own row
so each question is 5 rows
I want to randomise these in a new sheet
at the moment it (should) just copy them in order
the copying works - if i print(questions) they're all there
it just seems to fall over at the pasting to a new sheet phase >.<
> File "C:\Python34\lib\site-packages\openpyxl\cell\cell.py", line 207, in _bind_value
raise ValueError("Cannot convert {0!r} to Excel".format(value))
12:41
anyone have a working examople with pyside2 svgwidget, preferably in statusbar?
13:26
I always forget how to do this: my script, c:/AOC/day4/day4.py, wants to import c:/AOC/util/util.py. What would the import statement look like?
I have a feeling that the answer is "spin up a virtualenv and install util as an independent package, globally accessible anywhere within that env" which is a bit more work than I'm willing to put in for a ten minute task
import os
import sys
sys.path.insert(0, os.path.abspath(".."))
I think
then import from util import util assuming the util directory has a __init__.py
"manually change sys.path" is both a popular approach and one that is frequently decried as bad practice
e.g. the first two and a half answers of stackoverflow.com/questions/1893598/pythonpath-vs-sys-path
bah! What do they know?
I've decided to just put everything directly in c:/AOC.
That's what I did for AOC 2017. Uh, I think. At least that's how my github repository is laid out.
13:56
is util just a grab bag of Kevin's tricks or is it specific to the AoC question?
I think import bag_o_tricks reads just as well as import util
I agree
@AnttiHaapala enlighten me.
@Arne I think yesterday's puzzle was more numpy
14:03
I went full data science dataframe on that one
🐼🐼
that is a super clever solution btw. I must internalize that somehow.
@piRSquared Right now it contains only extract_digit_sequences, which gets all the numbers out of a string. Useful if you don't feel like writing 25 different regexes this month.
e.g. "[1518-07-10 23:58] Guard #1993 begins shift" becomes [1518, 7, 10, 23, 58, 1993]
Looks like today is going to be a "code works on test suite, but not on the real data" day ;_;
Have to sort the data first
Why they would keep logs out of order like that, though... :shrug:
First spy comes in going up. The next down. The one after that was drunk...
14:16
@AnttiHaapala huh, it didn't even occur to me to try it in less than O(n*n)..
My code worked for part 1 but not part 2, so I don't think it's a sorting problem. Not entirely impossible though.
Ah then nevermind, probably not
My money's on "off-by-one error"
Yep
-        for i in range(start, end+1):
+        for i in range(start, end):
did that fix it?
Yeah. They probably intentionally sculpted the input file so that the answer would change based on whether I assumed the wake-up minute counted towards the elapsed sleep time
14:22
Cbg
@AnttiHaapala I could be wrong but isn't parts = w[:j], w[j + 1:] still linear in the length of the input string?
@Kevin I bet you your code would probably work on some people's input.
For data that isn't constructed specifically to trip it, I expect this edge case would occur only rarely.
@MarcusAndrews yes, that's why he said O(l * n)
I must have missed that -- I only saw the comment above where he had said O(n). I think it's O(n l^2) though
14:25
And I was scanning the string length as well so my solution was O(l * n * n)
\o cbg, I'm still behind on AoC :\
@MarcusAndrews yes it is. But it is constant if the length of the string is constant ;)
mine scales linearly with the number of input items
@Kevin been there, done that.
@Kevin also, counter.update.
Nov 27 at 15:19, by Kevin
Show me a man that says he has never made an off-by-one error, and I will show you a liar ;-)
@Kevin shouldn't that be "Show me a man that says he has never made an off-by-one error, and I will show you 0 liars ;-)"
@piRSquared oooh clever!
14:36
I used the wrong data type and now I have 2.220446049250313e-16 liars
There are three types of people in the world. Those who can count and those who can't.
@KevinMGranger follow @AnttiHaapala's solution it is far cleverer.
There's two hard problems in computer science: cache invalidation, naming things, and off-by-one errors.
Or, the even better take:
There's two hard problems in computer science: we only have one joke and it isn't very funny
@piRSquared I combine:
Aug 16 at 13:14, by Antti Haapala
there are 10 types of people: those who do not understand binary, those who do, those who realized that this joke was in ternary and those who anticipated that it will contain an off-by-one error.
Who will write the error class OffByOneError. I want to see this helpful message OffByOneError: You almost had it!
Or OffByOneError: Sooo close!
@piRSquared that is brilliant
Meanwhile I was trying to figure out if you could do it with some sort of DFA
14:45
You can also store things by common prefix/suffix
Yep, that's what Antti did
Right now I'm wondering if you could model the whole set of names as a graph with each node being a letter, and use a somewhat similar strategy to the one for finding a cycle in a graph-- theoretically, a single deviation would mean two searchers would separate and rejoin only once, and they could track that
well, it is exactly that I stored the string with each character replaced with a non-existent character, except that I didn't make the string.
Set union is O(n + m) so now i'm not so sure wiki.python.org/moin/TimeComplexity
not so sure about?
the time complexity of the comparing is O(l * n) but you have to account for adding things to the set seen which is also O(n) so that might be O(l * n * n) still
Or am I not thinking about that correctly
14:56
@piRSquared the length of an id does not change as a number of ids change.
the inner loop runs only for the length of an id.
likewise with sort we say a sort has O(n lg n) time complexity in that with everything else in tact, as the number of elements changes, then, it behaves like that.
my code will run 2 times as slow for ids that are twice as long.
and likewise timsort will be slower for long strings that differ only in last character than short strings...
and no one says it is O(kn lg kn)
But every time you add a tuple to the set seen it takes longer and longer. I'm focusing on the adding to the set part.
no.
set insertion is O(1)
Ok, that is what I was missing.
Sounds like Antti and I had similar approaches for day 2. By my reckoning, we're doing it in O(l * n) time
"See dict -- the implementation is intentionally very similar."
@Kevin as I said ^, l can be considered as a constant, these were all fixed-length strings.
@Kevin there is also a possibility for mistake:
15:02
@AnttiHaapala yep, got it.
I assumed equal length. My code breaks if they are not.
aaaxbbb and aaxabbb, if you just glue the parts together, you can end up with aaabbb and aaabbb that look almost alike, even though they're not.
Hmm I still think that extra factor is l^2 at any rate -- here's a solution that attempts to avoid that in the average case: pastebin.com/raw/VRaDFGmu
15:20
Hm.
anyone know why an email.Message get_payload() would give me the entire email instead of the body?
ooo
hah. was missing a .strip() call at the end of my multiline string. Never mind, carry on.
wim
wim
15:46
@piRSquared argh! no!
@Kevin install util is right, it's about a 30 second task to generate a pyproject.toml file (or setup.py file if you're old school) and virtualenv is not really required.
That is definitely a stronger response than from naming a lambda. Ok, ok, I guess I won't recommend that again.
16:02
Wow, day two of AoC was much simpler than day one for me, at least the getting the run time under an hour part of day one part two....
@wim Is it possible to install util so that import util only works when my current working directory is C:/AOC and/or C:/AOC/day04? I was under the impression that it would be accessible from any directory on my machine, which I'm not crazy about.
util is a generic enough name that I'm sure all sorts of future projects will also have packages by that name, and I would prefer to have to chance of a conflict
Perhaps the answer is "no, you don't need to worry about that, because local packages have priority, so for future projects it will always choose your project's util over AOC/util"... But even so. I want to keep minimal the amount of global state in my environment, if for nothing else than on the principle of the thing
wim
wim
16:24
If you want it only to be working for a certain directory tree then you're pretty much describing the virtualenv use case (it's common to set up hooks into cd that activate/deactivate venv when changing dirs)
@Kevin although util is a common module name, it's not a common top level name. so 3rd party util would be namespaced anyway - there is not a conflict unless they are using implicit relative imports (which IIRC don't even work in python3 anymore anyway)
I just had a moment of "er why do I always overthink stuff". Serving js files that need to have dynamic values from environment variables (external endpoints urls, mostly), I was thinking about all kinds of complicated js file generation on server startup, whereas this solution opened my eyes to simple.. dependency injection using the already existing rendering system.
Oh, if future projects straight-up can't access it via import util, and have to do import AOC.util, then that minimizes the possibility of a conflict to basically zero
If so, I can live with that
Hmm, do AOC leaderboards have an "invite" url I can link to, rather than tell people to navigate to adventofcode.com/2018/leaderboard/private and enter a code there? I want to pin a message, and a hotlink would save me a lot of characters.
16:43
@Kevin is it a POST or a GET request in that form?
Let's see... POST.
GET would have been easier, I expect
I guess for the time being readers will have to join the hard way :>
Ok, I'll put up the url. If anyone complains they can't get in that way, I can always change it back.
wim
wim
you can edit even old messages?
No, but I can unpin that one and write a new one and pin the new one.
16:56
@Kevin it is not possible to use the URL
need to have the code.
Dang, I''ll pin a new version in a bit
(unless I get beaten to it)
I don't have the code
wim
wim
I suppose the leaderboards you're in are just associated to your session cookie (in which case a magic link would not be possible)
not session cookie but the identity.
IIRC the code is 119932-f5c26ae6
17:00
You can also join the global leader board ;)
wim
wim
@AnttiHaapala same thing, for all practical purposes
they need not be
wim
wim
the global leaderboard is depressing. how guys can solve it before I even had time to read the prooblem description?!
simple
skip the problem description.
If you like, join our Advent of Code Leaderboard at 119932-f5c26ae6, and/or share your solutions
10
17:02
@wim Maybe someone is testing out an AI bot?
they're using the time warp tech mentioned ;)
infer the problem from the example input...
wim
wim
I'm very detail oriented/perfectionist so it doesn't sit well with me to just skip down to the example input and hope for the best
First, create (2**16)**(25*2) user accounts. Each day, at 12:00:01, each account submits a different 16 bit integer as a solution. Delete all accounts that get an incorrect answer. On the 25th, you'll have one account with 50 stars and a sub-one-minute total solution time
@wim or ...
start from the bottom
wim
wim
17:04
@Kevin there are string answers too
first read your input.
or an excerpt of it.
for example note that "oh this isn't sorted"
then read the problem backwards.
@wim Ooh, that's a problem
wim
wim
and there was one where you had to print an ascii art code and read the damn string, remember
@wim I don't get it, either
17:10
The flip side of "there's no wrong way to enjoy AOC" is "only a limited subset of the ways to enjoy AOC can be quantified and formally ranked on the site"
The users that enjoy making a solution as fast as possible get lauded on the leaderboard; those of us that want a perfect solution, or a solution that works efficiently on an input a hundred times larger, or a solution that prints ascii art of dancing elves, won't get our name up in lights
[insert cliche speech here about how the Reason for the Season is [insert eusocial virtue here], not personal gratification]
@Kevin I would like to see a collection of the ascii art solutions, thanks Kevin.
<|:-)-/-<

<|:-)-|-<

<|:-)-\-<
17:29
when you pass [] as the second argument to pop will that remove the last array or will that put the first value into an array
As far as I know, you can't pass [] to list.pop.
for example neighbors.pop(queue.popleft(), [])
>>> foo = [1,2,3]
>>> foo.pop([])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'list' object cannot be interpreted as an integer
Possibly your neighbors object is not a list, in which case it's hard to say what its behavior might be. Check the documentation and/or source code for that class.
@pyeR_biz well, you didn't wait for too long. There are some problems with your question too... the first is that you don't have a question but 3. (= too broad). You're asking for libraries that could solve your problem (= off-topic, asking for offsite resource).
wim
wim
17:45
@Kevin TIL mental footnotes supported nesting
What is consciousness if not an algorithm recursively filling out a million mad libs in parallel
Aaargh, Windows does not recognize partitionless hard drives :( I should remind myself more often to be more forgiving of relatively small Ubuntu quirks and bugs
wim
wim
18:02
I'm pretty sure it does
haven't used recent versions of windows but there was something, probably called "disk manager" or other stupid name, which would show all the disks and allow you to create/modify partitions
I mean, I'd rather not partition it at all. It's already formatted as NTFS and has files
Although I'm running Windows through VM now, that could be the problem... That disk technically isn't real
wim
wim
oh, you meant does not "read" not does not "recognize"
Does not recognize the contents then
wim
wim
I wonder if you can create a partition table without destroying existing data. sounds dicey
Wikipedia says "The Windows Disk Manager in Windows Vista and Windows 7 utilizes a 1 MB partition alignment scheme which is fundamentally incompatible with Windows 2000, XP, OS/2, DOS as well as many other operating systems" which does not inspire much hope in me
I expect this sentence also applies to Windows 10, and they just haven't updated the page in a while
18:28
How do I use numpy.all() on a 2D array to check that all cells are True?
wim
wim
Why wasn't there a windows 9? Because 7 8 9?
IIRC, part of the reason is that too much legacy code has if os.startswith("Windows 9"): #must be 95 or 98 but there are other (perhaps more important?) reasons too
I'm going to bet that 80% of it is "because bigger numbers are more good"
SNAKES!!!!
I share this with you if you haven't played with this yet
it is quite fantastic
18:45
looks like I just need allclose() instead of isclose()
wim
wim
poetry is great, also check out flit (lightweight, opinionated, python3 only) and hatch
I searched The Old New Thing, a Microsoft blog mostly free of marketing spin, and found this, which indicates that he'll reveal the dark secret of Windows 9 in 2019.
@Kevin Windows 9 development was progressing with impressive speed and efficiency, despite a number of breaks and backwards incompatibilities with previous Windows versions...until higher ups realised it was essentially Linux with MS badging...
19:01
I would have loved to say I was using the windows distro of linux
The only remaining copy of Windows 9 is sealed under 100 tons of concrete in the lowest chamber of the Kola Superdeep Borehole, seven miles down.
Dark web informants say they buried it because it was awful. Think Atari's ET, times a million. But they're wrong. It's too good. Using it is like a dream. A dream you never want to wake up from. Half of the testing team never did.
That sounds terrible btw
@idjaw holy fancy, i like the name :D
Speaking of ET. I just bought NES Classic. I'm going to enjoy Zelda and Metroid
If you can figure out how to get past the room of eight darknuts in level five, let me know. That's where my run died last year.
Strategy guides suggest that I git gud
19:21
I'll let you know
I beat this game when I was 12 (I think that's how old I was) How hard could it be now?
19:33
@idjaw huh, it even supports lockfiles
I guess I'l test it after all =)
20:12
I'm confused by the rules in en.wikipedia.org/wiki/Left_recursion#Indirect_left_recursion. I don't know how you can get from B0A1a0 to A1a0. Where did B0 go? I think it must have something to do with the distinction between the => operator, and the =>+ operator, which I also don't understand.
Maybe the implication is that you can always remove terminals from the left hand side of the expression, as if the parser were popping them off of the token stack
But then I'd hardly call it "left recursive". It's more like... Middle recursive
Maybe "Note that these sequences may be empty" means that I should imagine that B0, and also B1 through BN, are definitely empty, which means I can safely remove them from the string
This page could benefit from a single semi-practical example
S := '' | A Q B
Q := '' | A S B
A := '' | 'a'
B := '' | 'b'
fig 1. A very circuitous grammar for "any number of 'a's followed by any number of 'b's". Left recursion makes it infeasible to create a recursive descent parser for this.
20:51
so I got a new motherboard because my old one randomly failed to correctly boot up my PC (or wake it up from sleep mode)... and the new motherboard fixed that problem, but in exchange it wakes up the PC immediately after it enters sleep mode. A small victory has been achieved today, but I have a new battle to fight.
@wim do you have an opinion on poetry?
nvm, you said it's great.
Looks a lot cleaner than the packaging I ended up doing. I ended up using conda to build conda packages. I'm not entirely happy with that approach. I can't use github but I can keep a local repo on disk internally and point to it with the toml file (I think). Now I'm wondering if it is worthwhile to change course now or wait to see if there is more dust to settle before I try to adopt a completely new way of packaging.
wim
wim
using a local dir as a pip index is not specific to pyproject.toml, you can do that since forever
21:10
Does anyone has any experience using Microsoft Graph API?
I want to build a tool using it from where hundreds of emails can be send out internally or externally by anyone in my company.
If we send emails though it, would it require SMTP server of my company or would it be of Microsoft's?
so much for Linux User ;)
That's why they are asking the question.
21:46
By the way, did we ever hold the Q4 meeting? There is no summary on the page, and I can't find anything on it in the transcript.
Nope, we've collectively completely forgotten. Sorry for the inconvenience
No worries. I only remembered about it because I wanted to propose something for the agenda.
New tentative date?
yeah, thanks for reminding
@Arne don't know, I raised it for the room owners
ok, thanks
I mean, yeah, we'll come up with a new tentative (or not-so-tentative) date, but we should make sure to find one that's less likely to be forgotten
personally, I was abroad last week and spent the previous few weeks preparing, which partly explains why I forgot
21:59
Cbg
No specific question, just curious if anyone has experience with Odoo?
Looks like, finally, the penny has dropped where I'm working that the system is not fit for purpose. I'm expecting to field some questions soon about free alternatives so would be nice to know if room 6 has any experience :)
22:14
@roganjosh I have a few months experience with ERPNext, none with Odoo. I'd still recommend ERPNext (given that there's no extra context provided)
Exp. includes customizing, setting up, migrating data & maintaining it for multiple clients. I love the new versions and the continuous developments, hence the recommendation.
I'm afraid I can't give too much context because they have a single monolith from 1984 that people have started really losing patience with, so I think it will be dismantled soon. I do know that theyll not be up for buying a system (I've come to accept that), but I better come back with some ideas on how they might structure things transitioning going forwards
You can (freely) host your own ERPNext system on your own / cloud infrastructure.
But yes, it will still incur developer time, specially for the data migrations and customizations if any.
I've used OpenERP (As a user not developer) so thanks for lifting the blinkers, I'll be sure to look into it
odoo.com/groups/community-59/community-32937746 might help with the comparison. Old, but still valid IMO. And of course, it only discusses the 2 Python based ERP softwares, not other more popular (and expensive) ones.
That's really useful, thanks
22:30
does anyone know answer to my question?
Thanks
At least on my phone, the lines of your question are cut off so I can't even read the question
@LinuxUser If anyone knew, they would've chimed in by now.
22:44
@shad0w_wa1k3r for the actual load from the factory, my own desktop with 16GB RAM would be fine for something like a Flask App. Do you have any opinion on whether a Proof of Concept server for ERPNext might run on that? I don't know whether the server itself guzzles resources
yes, from my experience 1.5 years back, ERPNext was RAM hungry. As much as Chrome back in the day (some might argue the same for today but I believe it's improved a little at least).
Presumably it just copes with whatever you put it on and doesn't need a proper server for a PoC but I've never run that kind of thing
Awesome, thanks
You need it for a PoC or production? PoC 16GB is gracious. 16GB production is okay to good depending on the data size and users.
Only for POC. I've seen the 30 day trial but I wouldn't be able to do jack with that much coming from no experience so I'd need a local box to just try it out
@roganjosh 4GB is more than sufficient in that case. Unless you start off with actual data migrations. Also, unsure of the 30 day trial you talk about, just refer to the installation instructs on their github for the hosting part, and the user manual for setting up part.
22:52
They have a 30 day free trial of a cloud server, quite prominently advertised on their site
ah okay, you can ignore that. It's like Coursera trying to sell you the specialization, but you can take up the courses for free (you of course don't earn any certificates though).
Yeah, I know :) it would just be less hassle than lugging a desktop to work :P
you're in for some craziness for at least a couple of hours :D
If it will run comfortably on 4GB I'll just shove it on the laptop and play with it when I'm waiting for my simulations to run. Puts me on the front foot
23:02
does the append operator += mutate arrays or just copies them?
lists?
Use print(id(my_array)) before and after. That will tell you if it's the same object
or old = new; new += ...; compare old with new
strange same id.
so mutation
What is strange?
23:09
that the array is mutated
@roganjosh I think he believes old = old + new should make the left old different than the right old
old = old + new would copy
old += new doesn't
yeah, but += is like that, I'm just playing the guessing game here :-p
@shad0w_wa1k3r But the question was specifically about +=
yeah, shouldn't play the guessing games. Need to master the art from Kevin before I delve deep.
23:12
i am just interested in +=
:P and I'm on a phone so, by the time my messages come out, I come across as some idiot that just parrots the general consensus :P
Andras must go through 3 or 4 keyboards a year at his typing speed
a+=b calls a.__iadd__(b) if that method exists which can return a mutated object that gets rebound to the name a
otherwise it's equivalent to a = a + b
(I think)
sorry, typing with one hand now, dog sleeping on the other :P
Reduced to a crippling 80wpm :P
that makes sense, I just notice that a "for in" loop will continue in python on mutation wherein js it does not. I thought it was interesting
(I almost commented, in jest, that roganjosh would "with time, become like the other parrots on phone :-p")
23:17
I would be baffled either way! I'm missing a reference here sorry :/
@Rick It's easier to think when you realize that "for in" looks for the "next" thing in the iterable. And if you keep modifying the iterable, the "next" can always keep coming.
@AndrasDeak then I'm a bit lost on the "rebound". The name a exists in both cases, so what would be the distinction there?
so it's like a generator
but that makes sense, I thought the same thing
@Rick on similar lines yes, but not the same.
a = ... would bind a new object to a but that object happens to be the same object as before
probably ambiguous phrasing on my part
23:22
Fair enough
23:50
If new properties are added to the target object during enumeration, the newly added properties are not guaranteed to be processed in the active enumeration. " I guess this means it's up to the discretion of the engine"
wim
wim
@AndrasDeak yes, however the existence of __iadd__ doesn't guarantee that existing instance is used again
well __iadd__ might return object() for all we know
or even better: None :P
wim
wim
for example, collections.Counter used to make a new instance with += and at some stage started re-using existing instance
I see
Counter doesn't implement __add__, right?
@Rick I would like to think it's not at the discretion of the engine but depends on the input and what is being done with the data (some strange edge cases that my sleepy brain can't think of at 4am)
wim
wim
23:58
@AndrasDeak it does
wim
wim
it would be pretty useless if you couldn't add counters
So did the implementation of __iadd__ change, or did it just appear?
wim
wim
it appeared
So this doesn't really support your earlier remark as an example, does it? :P
wim
wim
23:59
but its appearance changed the behaviour of += in backwards incompat way

« first day (2971 days earlier)      last day (2202 days later) »