« first day (3970 days earlier)      last day (978 days later) » 

1:14 AM
anyone else noticed a user on main, who specifically edits answers to remove "hope it helps" and other derivatives? such dedication from them :o
 
cbg
 
cbg
 
 
2 hours later…
3:23 AM
@kalyanirajalingham well i searched online but most of online resources are for beginners not for intermediate or professional practice , i want to enhance my skills
any book or course for effective and better ways
 
3:37 AM
@SAJW Sometimes, you want to know the next value of an iterator without advancing the iterator to following value. So we were exploring various ways to "peek" at that value. Aran-Fey originally just wanted to know if the iterator is empty. My code doesn't actually address that issue, but it can easily be modified to handle that.
 
@PM2Ring so you want to know f(x+1) without changing x by 1?
for example
 
3:55 AM
Greetings from Vancouver Island, Canada. I'm trying to get better at asking basic Python questions and, after 4 questions that have been answered quickly (like within minutes) and correctly, I'm now getting a warning that says, I might get blocked from asking questions. If I put up "how do I" and then in a comment, somebody says, do this, and it works, to me that's stack at her finest. What am I missing? Any thoughts would be helpful so, as a Newbie, I don't get tossed.
 
4:18 AM
@RickSegal hello Rick, have you checked meta.stackoverflow.com/questions/255583/… to see if that applies to you?
not to demotivate you, but if the questions you ask are indeed basic questions, then you dont have to ask a new one, most of the basic questions have been answered by now, so you most likely are going to get dupe votes on your questions
 
@python_user, hi. I try particularly hard to look first, show the code, and explain the intent, etc. For example, using filedialog.askopenfilename(), I got the name but wanted to just grab the file path to the name. os.path.basename() does the trick and was in the comments vs. an answer. There are no votes, no edits, etc. Those are the sequence of events on the last number of questions, all of which, helpful, long time users, answered for me. i did read the info you sent me, thank you.
 
4:40 AM
I dont know much about this, but you could wait and see if things get better, in the mean time, you can mark any answer to your question (that works, if any) and check if that helps
you can even mark your own answer as a solution
 
@RickSegal I would suggest to accept the answer from Tim Roberts, and also upvote it
 
5:01 AM
?
 
@U12-Forward, done, thanks!
 
I don't think you did, you have to click the tick for marking as accepted, check here stackoverflow.com/tour
 
@U12-Forward, I just checked, and it does show upvoted. I can send you the screenshot. When I hover over it, I get the option to undo it, so I assume it is my upvote.
 
@RickSegal You should accept as well
click the tick
arrow
That ^
 
@U12-Forward, oops. Yeah. I upvoted and totally missed the check box. Many many thanks. It is a joy being new at something/some place, eh?
 
5:09 AM
Yeap!
 
@RickSegal it's not really a warning - more a notification
hey @PM2Ring :)
 
@RickSegal Here's some more info on accepting: How does accepting an answer work?.
Hi, Jon!
 
cbg guys
 
@PM2Ring I'd like to ping an idea over to you - have you got an email I can reach you at?
cbg
 
@JonClements I try to avoid email, as much as possible. ;)
 
5:20 AM
okay, any preferred form of contact?
 
Not really. I do have a pm2ring email on Yahoo, but I rarely look at it. Most of my social interaction these days is on this network.
 
@PM2Ring, thanks!
@JonClements, that's a relief! Thank you
 
I suppose I can post my email address here, and then delete it...
 
@PM2Ring You could just go start a private room with Jon :)
and make sure nobody else watching and post it...
 
5:43 AM
@PM2Ring, I have my eyes closed and won't look! :-)
 
hey guys can some one help me with a little issue
import re

test_str = ['John Wallace','Steve King','Martin Cook','Adam Smith','Irene Peter','Alice Johnson']
for i in test_str:
pattern = re.search(r'([a-zA-Z]+)\s([a-zA-Z]+)' ,r'\2,\1',i)
print(pattern)
why i am getting this error TypeError: unsupported operand type(s) for &: 'str' and 'int'
 
Because you're calling re.search instead of re.sub
 
oh my bad ,thanks man
 
6:11 AM
Folks,
This command in my program works:
os.rename(just_dir + '/'+ grab_one,just_dir + '/' + testname + ext)

my question is how do I assign the results to a variable or how do I print out the results of the rename.
 
ohh wait, nvm
 
Found it:
https://stackoverflow.com/questions/32774160/how-to-use-variables-in-os-rename
 
6:54 AM
cbg guys I am back
 
7:12 AM
Hey guys
Somebody just downvoted three of my posts in the same time...
What should I do?
 
@U12-Forward, We can do nothing about these. If a single person just randomly downvotes several of your posts (questions/answers), such downvotes are removed after some day after when SO algorithm detects it and moderators verify that
 
Hope so
3 downvotes within a frame of 2 mins
Actually more like 30 secs
 
Well, I'm back. The solution to the os.rename was not actually what I needed.

os.rename(just_dir + '/'+ grab_one,just_dir + '/' + testname + ext)

That line of code works for me, no problem. I can find, select, and rename files. This is for me to go through a lot of files with DSC000.NEF on them and put real names in the place of DSC000. It all works but I can't seem to make a simple print statement that says:
Print("You named: " + old_name + " to " + new_name) where new_name is the result of the os.rename result.
 
7:27 AM
They're just strings that you're passing to os.rename(), right? So you can print them just like any other string
You don't need a return value from os.rename()
 
@roganjosh, thanks for replying. Actually, yeah, you're right just print the same stuff I sent to the command. That's the blindingly obvious, eh?
 
7:45 AM
@U12-Forward, I think that might be targeted downvote, just a thought but not sure.
 
@ThePyGuy, what does targeted downvote mean?
 
@RickSegal, Like sometimes some people get offended by some user, and they just start randomly downvoting their posts, something like that.
 
@ThePyGuy haha yeah but I didn't offend anybody :D
 
@ThePyGuy, gezz. Seems harsh to mess with somebody like that but, the world we live in these days, I guess.
 
@U12-Forward, Its not in our hand whether someone gets offended by us even if we do nothing to them. We have no option but to ignore
 
7:49 AM
@ThePyGuy, but is somebody is new, say like ME, and you go downvote everything I have up, which isn't much, I can end up getting banned, no? totally out of my control.
 
And these days, Questions/Answers with pandas tag have active downvotes for fairly simple questions or not so well written questions. So, don't get surprised if you get downvote on a pandas tagged post
 
Should I even ask what a pandas question is? Why that's bad?
 
@RickSegal, there are some privileges' who can downvote or what are the maximum number of votes a allowed a day
 
@ThePyGuy Yeah just 6 rep I don't care lol
 
@RickSegal, pandas is a well known library in Python.
 
7:51 AM
@ThePyGuy yeap! lots of serial downvoters
 
@ThePyGuy, thanks. New and I'm not there... yet.
 
haha
 
@RickSegal pandas is a python library for working with tabular data (kind of like Excel in Python). And the tag is flooded with duplicate answers
 
I mean downvotes are completely acceptable, and they are useful as well, but at least, had downvoters left some comment for the downvotes, that'd have been even great.
 
@ThePyGuy Yes exactly
If we would know who downvoted I could just ping them and ask why haha
 
7:54 AM
Haha, that's the reason why they don't let you know @U12-Forward
Otherwise, they'll be asked for the reason for downvotes
 
@ThePyGuy Yeap!
If there was that rule there would be much less downvotes
 
@roganjosh, thx. will look into that when I get more comfortable with driving this Python puppy. Fun times.
There should be a requirement as that's the only way to learn. Just, meh, you're a clown = downvote is not exactly cricket.
 
Actually, there probably aren't enough downvotes these days, which is why a lot of of the regulars aren't even trying to keep on top of the main feed
 
I've been told Stack is now a kinder place to be asking coding questions. I guess 5 - 10 years ago, it was brutal. You ask how to get user input and you'd be flamed to a crisp. Now, it appears, you get the command in a comment with the link to the core documentation and a newbie tutorial. So, I'm told.
 
@RickSegal, that is true, unfortunately.
 
7:59 AM
What you get with that new kindness: Garbage and/or duplicate answers rather than a ground truth
A lot of the time it's the blind leading the blind. Is that progress? I taught myself during this, apparently terrible, period where people would criticise my code. And look how I turned out!
 
@roganjosh, true I suppose. Not sure where the balance is. Being new, the hardest part about asking a question is not knowing enough to ask it in a way that seems to be 'acceptable'. Your answer to me here, for example, was a perfect Q -n- A but for me. In core stack world, if I asked that? Time to die..
 
But it should die on the main site. It's not a helpdesk, it's supposed to be a repository of information and your problem just isn't really generalised. That's why we have chat (though SE doesn't invest anywhere near enough into it)
That sounds cruel, but it's the main reason that people can find info on SO in the first place. It has to be curated
 
Yeah, I actually still if a newbie asked a question, not well formatted but at least understandable, I would post an answer (if it's not a duplicate) and will upvote the question
I understand sometimes newbies don't know how to ask so good
as long as a question is understandable and contains minimal code, I will upvote and answer if i can (or close as a dupe)
 
@roganjosh, fair enough. Do you think there is a way to frame my question ( the above example, thanks again) so that is would be a repository of information? I appreciate and don't think it is cruel, at all, more of a here's how to use SO properly.
 
No, because it's just printing strings, which has been answered before
 
8:09 AM
Ok. I get it/appreciate the dialog
 
It's very unlikely that newbie questions will gain much traction on the main site. The problems will just be from not piecing together existing answers correctly
 
That I agree with.
In the case of the above, the real 'learn' is the parameters of os.rename are src and dest which are strings, hence, well the 'duh, got it' from me.
I suppose the go do research first, should have resulted in me discovering that/being reminded and then figuring it out. That's fair and no, it is not a helpdesk.
 
Spoiler: the protagonist of a fictional series will survive till the end by every means
 
But it was fine for chat. We got to the bottom of it pretty quickly, right? I don't begrudge people asking such questions in chat; we all benefit from another perspective at times. It just doesn't belong on the main site because it was so localised
 
is storing (hashed) passwords only really good with a database?
 
8:15 AM
Where else would you store them?
 
@RickSegal I think your posts are good! you never got downvoted
 
like maybe in a csv file
 
Usually new users always get downvoted!
But you never did yet!
 
@U12-Forward, so far, knock on my head (wood), trying my best! :-)
 
Keep up the good work!
 
8:17 AM
@SAJW I can't immediately think of why a CSV would be less safe than a database, other than user access controls on your own side (i.e. employee permissions). But it cannot be indexed and queried
 
@roganjosh, concur. chat worked great and I'm rolling along.
 
@roganjosh ok, so if I want to experiment with hashes, I kinda have to setup a database on my laptop?
 
Just use sqlite3
 
@U12-Forward "I live where you live" = EPIC! Nicely done.
 
conn = sqlite3.connect('test.db') ... you've just "setup a database on your laptop" :P
 
8:20 AM
@RickSegal haha
 
@roganjosh thanks very much :D
 
@RickSegal Want to keep where I live private :D
 
SQLite is a lot more powerful than it typically gets credit for. CSV/JSON databases are, IMO, folly. It' much easier to use SQLite and, if the time comes to upgrade to something like postgres, it's so much easier to port over
If you use SQAlchemy, even without the ORM, it's even easier to port code between databases
 
@roganjosh, back in 2000, I was a venture capitalist and had an investment in a first generation online grocery delivery service. The biggest pile of complex code for the whole thing was routing trucks around Toronto and the GTA. I seriously admire your CV. Being able to do that kinda work: <salute>
 
and is an entry in an account dbase like this: username/hashed pw/ unique salt ?
 
8:27 AM
@SAJW the salt is stored with the password for you
@RickSegal ha, thanks :) It's getting a bit overwhelming atm but getting there :P
I only hope that you kept your shares?
 
Company got sold to a bigger one and, we did okay.
 
2000 was way ahead of its time, thinking about it. We barely had interwebs
last-mile now is just silly in its growth but in 2000 I don't even have a sense for the market there. It feels like the only home delivery was post or milk :P
@SAJW What are you using for your hashes here? I misspoke a few days back when I said hashlib instead of passlib
 
I thought hashlib.scrypt, but well I am still looking for the answer to that qestion.
 
Go with passlib
I think that's my bad, sorry :( It'll all get handled for you in passlib
 
Ok, and which algorithm to use? I read that scrypt is decent because the computation is best on a PC, so the attacker has no edge with a GPU setup
 
8:42 AM
The salt+password+number of cycles is all stored in a string that can be saved in a single column
I'm not familiar with scrypt and this is one area where I don't want to speculate. All I can say is that I've used SHA256 in the past
 
Is an offline attack the worst that can happen? Should one insist on changing passwords in the time it takes to make an offline attack?
like every month
 
Well, no, the worst that can happen is that you lose admin control of the whole database?
 
Sure thing!
I meant from all of the attacks
if someone gets a copy of your database and you can't recognize this, what you do? assume it happened always?
 
Things to consider: obligatory xkcd and that forcing users to update passwords at intervals tends to have bad effects [citations I'm thinking of needed]
 
I am still not sure if a passwordmanager is the thing...
if I get amnesia, I am **** like before
still, better than to have them all in my browser of choice
 
8:51 AM
@SAJW After further testing, I've decided that my peakable function is rubbish. Please ignore it. :(
 
@PM2Ring but getting f(x+1) was the goal?
 
@SAJW Sort of.
 
is it true that the linux password trunctates after 8 characters?
what was the reason for that? o_O
 
9:10 AM
@SAJW Some ancient systems had a password length limit of 8 chars because they used DES. From superuser.com/a/202245 Also, if you have a hash which does not start with $num$ then you are using DES and that is limited to 8 character length.
en.wikipedia.org/wiki/Data_Encryption_Standard DES has been considered insecure right from the start because of the feasilibity of brute-force attacks
Cryptography has made a lot of progress since 1975, when DES was published.
@roganjosh scrypt is very good, and it's in hashlib. en.wikipedia.org/wiki/Scrypt It's from 2009, so it's old enough to be well-tested, but not so old as to be superseded.
 
It is but with a big warning header
 
it's in hashlib and passlib :)
 
One important feature of scrypt is that you can tune it to use a large table that consumes lots of RAM, which makes it expensive for a brute-force attacker to run lots of attacks in parallel. It's possible to run the algorithm with less RAM, but that requires a lot more CPU power (to basically compute the RAM table values on the fly).
 
oh ok, then I use argon because I have no clue ;)
 
tbh I didn't know about argon2 until this discussion happened, so I have some research to do myself
 
9:26 AM
somehow password cracking is alot like gambling on a slightly +ev slotmachine imo
 
Argon2 is definitely the modern favourite. It's still fairly new, and a lot of sites prefer to be more conservative and use slightly older password hashing algorithms.
 
It's a race to the bottom. It's kinda sad that there's a branch of humanity that will put so much brain processing power into stealing vs. building. But, such is life.
For now I'd probably stick with SHA256 but I'm not having to deal with user credentials these days. Still nice to know there's a "new" kid on the block if I go back to having to deal with passwords :)
 
Argon2 won an international hashing competition. Its future was looking very rosy, but then some minor faults were discovered. Those faults were quickly addressed, but that sort of thing makes cryptographers nervous. So there has been a fair bit of scrutiny of Argon2, looking for other stuff that its creators might have overlooked.
 
is passwordminimumlength=15 enough or do I need to weed out stuff like password1234567890?
 
What is it that you're actually building? Atm you've gone from CSV --> SQLite so I wonder whether you're over-thinking?
 
9:35 AM
Yes! You're right, was ovethinking
 
There are probably better sources of info for password policies. I actually really appreciate that you're taking this seriously, but it's gonna be quite hard for us to give proper advice for your specific application
 
@roganjosh Using PBKDF2 with a SHA-256 HMAC is still perfectly fine. For that matter, even using it with a MD5 HMAC is safe, if you do enough rounds, even though MD5 itself is no longer considered to be secure for purposes like document signatures. The HMAC algorithm isn't affected by that vulnerability.
@roganjosh That's not a bug, it's a feature. ;) But it does mean that scrypt can chew up a lot of server RAM for legitimate users. The point is to make it chew up attackers' RAM. More modern password systems let you increase RAM usage independently of the number of rounds.
 
Oh sure. I didn't mean to suggest it was a bug
 
Mmh, what would be a basic implementation of the storage of userrights? simply columns for the specific rights or a byte where every bit is one specific right?
 
I have no idea what that question is about
userrights is not a fixed and known concept (or not to me, at least)
 
9:47 AM
@SAJW Are you familiar with Diceware? en.wikipedia.org/wiki/Diceware
 
@PM2Ring sure looks decent, I only knew about passphrases from the xkcd comic. That takes it to a new level :)
 
Are we talking about OS rights now?
 
I just wondered for what an account is used in general
with an account usually comes something to do with
like in an OS or on a forum
but that might be really offtopic here
 
One concern with scrypt is that it's the basis of several crypto-currencies. So there's now a profitable industry in producing specialised hardware that does scrypt hashes. That hardware can't exactly be used to crack scrypt password hashes, but it's possible that someone could create a chip derived from that hardware that can crack hashes. That wouldn't break scrypt, but it would increase the number of rounds needed (and amount of RAM) to keep things secure.
 
import sqlite3

con = sqlite3.connect('accounts.db')
cur = con.cursor()
cur.execute('''CREATE TABLE users
               (username text, hashed_password text, comment_right bit)''')
comment_right should simply mean if the user is allowed to comment
 
9:59 AM
This is not an extensible way to build a database
 
@SAJW BTW, "weeding out" is generally a BAD idea in crypto because it reduces entropy. Instead, you need to add a salt that has enough entropy so that it doesn't matter if the password's entropy is on the low side. Of course, the password / pass phrase still does need a fair amount of entropy to be usable.
 
Simply put - you need to have an id column as a primary key on your user table, and the permissions go into another table
 
One of the flaws of the Enigma machine used in WW2 was that it never encrypted a letter to itself. That reduced the entropy, and made it possible for the Allies to crack the code.
 
@PM2Ring I know that fact, but I can't capitalize on it.
I mean I couldn't crack enigma on one afternoon
 
@SAJW You might enjoy doing the Cryptopals challenges. cryptopals.com A bunch of the regulars in this room did them a few years ago. I got about halfway through set 3. Some of the instructions are a bit vague, which can be annoying. But I had fun, and learned a few things.
 
10:18 AM
is "correct horse battery staple" actually a good password?
 
well not now anymore I suppose
 
I am more inclined to the idea of using four common words instead of "1337" in my passwords, which I reset every other month
 
Tis the way things should be. But often we're forced into archaic password patterns
 
you are right, even if I want to, most sites wont let me, the regex validation or whatever they do wont let me enter just words :(
 
10:54 AM
Hi everyone, I have a question with active bounty of 500 reputation (bounty has been started for the second time on this same question), and it is going to expire in next 18 to 19 hours, but I have not received any answer to the question. It'd be great if you guys could answer it: Different behavior while reading dataframe from parquet
 
11:52 AM
rbrb guys
 
12:43 PM
recbg
 
1:10 PM
@Kevin just to note that the wikipedia article is better as an entry level introdcution: en.wikipedia.org/wiki/Timsort
 
1:24 PM
Hello
 
 
3 hours later…
4:42 PM
how do I remove the `\` here?
def foo(seq):
    if isinstance(seq, (list, tuple, set, dict)):
        if isinstance(seq, dict):
            seq = seq.values()
        return 'something' + str([foo(i) for i in seq])
    return type(seq).__name__


seq = [
    {
        "key_1": "string",
        "key_2": ["some", (1, 2, {2})],
        "key_3": {1: True, 2: {True: {1: False, "key_4": set([1, (1, 2)])}}},
    },
]

print(foo(seq))
the output just has \ , how can I remove that without having to call replace('\\', '')
 
I don't think str([foo(i) for i in seq]) does what you want. I'm not sure what kind of output you do want, though.
 
the output I want is foo(seq).replace('\\', '') without having to do that (replace), and I do need the to add the list with [], no reasons, just playing with this
Tried f strings equivalent and same results
 
The output you want is something['something['str', 'something['str', 'something['int', 'int', "something['int']"]']', 'something['bool', 'something['something['bool', 'something['int', "something['int', 'int']"]']']']']']? Really?
 
yeah, like I said, I am just playing with this, no real world usage
where are the \ coming from?
to clarify, I dont mean to waste anyone's time with this toy example, the question here is how they appear and how can I not make them appear without a replace
 
I don't think there's an easy way to achieve that output tbh, probably because it's a weird thing to do
They appear because you're essentially calling repr on a string a dozen times.
>>> print('foo')
foo
>>> print(repr('foo'))
'foo'
>>> print(repr(repr('foo')))
"'foo'"
>>> print(repr(repr(repr('foo'))))
'"\'foo\'"'
>>> print(repr(repr(repr(repr('foo')))))
'\'"\\\'foo\\\'"\''
You're not directly calling repr of course, but printing a list does that for you.
 
4:54 PM
so for these str and repr are the same?
 
What are "these"?
 
I mean, I do the explicit str on the list don't I?
 
Yes. Now, how does a list str itself?
By calling repr on each element.
 
ohh, ok, I didn't realize that part, calling repr on each element
thanks
 
Hello!
 
5:01 PM
cbg
 
5:13 PM
@Aran-Fey return f'something[{"".join(foo(i) for i in seq)}]' after some trials, this works, in case you wanted to know
kinda hacky and also ugly
 
something[something[strsomething[strsomething[intintsomething[int]]]something[boolsomething[something[boolsomething[intsomething[intint]]]]]]]? That's not quite the same output you said you want earlier
 
it removed all the quotes too, ok I am blind
I should go to sleep now
ok not just quotes
 
@ChrisP how many times do I have to kick you for you to understand that?
 
Admittely, adding quotes and commas and spaces is an easy task. But that still won't give you that exact output, because it uses a mix of single and double quotes.
 
5:18 PM
yeah you are right, maybe I will get back to this next weekend
 
5:47 PM
Hello. I would to know please about running time of a list in Python. Do we have a linked list in Python?
 
You could make a linked list if you wanted, but I'm not sure what you're asking
 
@roganjosh. Thanks Rogan for the reply. I just want to know if we have a linked list in Python please. I don't want array-based linked list.
 
collections.deque is implemented as a linked list.
 
I am asking about ordinary linked list
@MisterMiyagi. Thank you. One side question please. What do you think the running time for not array-based linked list you referred to?
If we have array based, then the problem boils down to implementing famous sorting algorithms, but for object-based list like linked list, I guess running time for search is O(N)?
 
FWIW, the array based list type is usually significantly faster even for O(n) operations in practical cases. The speed of data locality easily beats algorithmic scalability.
 
5:51 PM
It does not chage
 
@Avra 42.
 
@MisterMiyagi. Thanks. Yes that's true, how about object based please?
 
I have no idea what that means.
 
Is it true it needs O(n) in Python similar to Java and C++ please?
I mean linked list where each node is connected to another with a pointer
This is naive linked list that is not array based
 
Yeah, that's deque in CPython.
 
5:53 PM
@MisterMiyagi. Thanks! What is the complexity of that please?
In Java it's O(N), where N is the number of elements
 
But a data type itself isn't O-anything. Specific operations have space/time complexity.
 
Complexity of what?
 
@Aran-Fey. Linked list or deque as @MisterMiyagi said please
 
@Avra Please see this reference. Your questions are not clear at all
 
A linked list doesn't run, so its run time is O(undefined).
 
5:55 PM
TIL that deque doesn't have a sort method.
 
A visual representation of a linked list:

[1] -> [2] -> [3] -> [4] -> ... [n-1] -> [n]
@MisterMiyagi. Not sort, I mean search please
 
@Avra Searching is O(n) regardless of the memory layout. It depends on whether the items are ordered.
Note by the way that so far the only algorithms you hinted at were "sorting algorithms".
 
@MisterMiyagi. In Java for example, linked list that is not array based has to be searched in O(n) regradless of it's array based on object based as I show above
 
@Avra Depends. Are the list elements sorted? Can the list be interpreted as a heap/tree?
 
@Aran-Fey. I am not sure about Python, but I guess deque is the one as @MisterMiyagi said
@MisterMiyagi. Thanks, so O(n). I see. Appreciate it.
 
5:59 PM
*wiggles their rearview mirror*
 
What I'm trying to get at is that you're once again asking a nonsensical question, because "searching in a linked list" is not a well-defined algorithm. There are many different search algorithms that can be used on a linked list.
The algorithm "loop over the list until you find the element you're looking for" is O(N).
 
@Aran-Fey. Thanks for the clarification.
 
FWIW, linked lists generally don't allow addressing individual elements in O(1), so O(N) should be the best case for searches.
 
True, I admit I didn't think that far ahead
 
I only know it from a recent attempt at Lisping, TBH.
 
6:05 PM
@MisterMiyagi. Thanks. Do we have double linked list in Python!
 
"A deque (double-ended queue) is represented internally as a doubly linked list." is literally the opening comment on a deque in the link I gave you
 
Well, yeah, that's deque.
 
@roganjosh. I see that. Sorry. Thanks.
 
Did you mean to ask for a singly linked list before? Not that it matters for searching, mind.
 
Deletion there is O(1) in deque
 
6:07 PM
It's O(n) in the general case.
 
Only from the start/end
 
@MisterMiyagi. Best case O(1) I guess
 
@MisterMiyagi In the general case you only pop from one of the ends ;P
 
TBH linked lists are pretty bad for anything that isn't operating on the start/end.
 
@MisterMiyagi. Yep! I was just looking for speeding hashing
It does not seem to work at all
This is the worst idea I am trying to make
 
6:09 PM
Just realised that 50% of my usage of deque is a waste... :/
 
Linked list is very old probably?
Todays usage is restricted to ArrayList
Even for saving posts, hashing is preferred
@MisterMiyagi. What is the best usage case you have ever had with Linked Lists (deque) please?
 
Reading my link, "Other Python implementations (or older or still-under development versions of CPython) may have slightly different performance characteristics." gets me thinking - can a compiler ever change the time complexity of operations on a collection? I'm guessing "no" but I'm wondering there's "one weird trick"
 
deque works best for a pair of separate producer/consumer. It's ideal to represent stream processing.
 
As in, a JITer isn't going to be able to upgrade a collection to another type or something like that
 
@roganjosh PyPy has some neat tricks to change the layout of lists, but I'm not sure whether they have any magic for deque.
 
6:14 PM
@MisterMiyagi. Thanks
@MisterMiyagi. You mean when you try to record the start and end of a stream please?
 
Ugh
 
@MisterMiyagi thanks. I shall do some digging :)
 
@Avra I mean when the deque is the stream.
 
@MisterMiyagi. Thanks. So back to deletion time of deque (doubly linked list)
@MisterMiyagi. Is this a writing typo?
This is for hash chaining with doubly linked list
 
@roganjosh I've only found two threads that I'd TLDR as "no one loves deque but it's still faster than CPython *commits* now"
 
6:20 PM
@Avra I think they're assuming you have access to a Node in the list. Then you can delete in O(1) time like node.prev.next = node.next; node.next.prev = node.prev
 
@Avra You should check whether the description is for a literal linked-list, where the entire container is one "thing", or for a colloquial linked-list-that-is-actually-linked-nodes, where each item is a thing itself.
 
@Aran-Fey. That's true, so why it's O(N) for single linked list and O(1) (constant time) for doubly linked list as you said where each node is connected to prev and next please?
I see why it's O(N) for single linked list
But the question about doubly linked list
I am not sure how having next and pre at each node will change time from O(N) to just O(1)
 
How do you delete a node from a linked list?
 
In a doubly linked list of nodes, each node can address its neighbours in O(1). Since deletion works on the neighbours, that's sufficient.
 
@Aran-Fey. I keep looking node.next starting from head till I raeach the key?
(head) -> [1] -> [2] -> [3] -> [4] -> ... [n-1] -> [n]
 
6:24 PM
Then you've found the node you want to delete. But how do you actually delete it?
Remember, we're assuming that you had access to this node from the start. There's no need to loop over the list to find it.
 
I just ahead if the key is found node.next.val
I take temp at node.next, then temp = node.next.next, then I do deletion Worst case is O(N)
 
> then I draw the rest of the owl
 
Can you please write in complete sentences? This discussion is starting to grate on me @Avra
 
@roganjosh. Sure. Sorry for that.
 
Ok, so in a singly linked list, you have to loop over the nodes in the list so that you can find (and update) the predecessor of the node you want to delete. So then how about a doubly linked list? Is this also necessary there?
 
6:32 PM
@Aran-Fey. Thanks
@Aran-Fey. I see! In worst case, we have to loop all the way from begining if we are to delete the last element, taking O(n), but that could be done in O(1) in doubly linked list
 
 
1 hour later…
Closed
 
thx
 
 
4 hours later…
11:48 PM
Hi there :)
 

« first day (3970 days earlier)      last day (978 days later) »