« first day (1991 days earlier)      last day (2948 days later) » 

12:06 AM
@TheQuantumPhysicist you'll need to use one of Python's concurrent solutions to perform concurrent Python code. QThread can't bypass the gil since it's still executing Python code.
 
@davidism I'm thinking of using "multiprocessing". I read that it gets over GIL. I need advice on the best way to make my class calls with multiprocessing.
The problem is that everything I tried has a problem... either I have to change lots in the QThread class, or I'll have a tough performance hit... @davidism
 
ProcessPoolExecutor is the simplest way. You could subclass QThread and override it's run/other methods to use that if you really want to keep using QThread.
you don't need to ping me every single time, I see when you post
"everything I tried has a problem" is not a problem statement we can help you with
 
It says there only picklable objects can be executed and returned...
that doesn't include methods of the derived class from QThread, right?
I understand, and that's why I'm listening to ideas to say why they're problematic, like I just did :)
 
I don't know, did you try pickling something like that? Also, you wouldn't be picking the thread, you'd be pickling the data you're sending to the function to perform in the other thread.
 
Pickling would give me a serious performance hit! It'll serialize everything in my class and send it to the thread, and then back from the thread to me... that's horrible!
 
12:11 AM
Sorry, this isn't really the place to have a call and response session where we solve your problem for you. Try something first.
You're using Python, get over it.
 
I did try stuff... lots of it!
I spent easter trying stuff
Get over what?
Is there a way I could make my QThread's contents shared in memory and then parallelize my calls?
 
Probably, but that's way too vague/broad.
Why not read up on multiprocessing? There's a lot of good information in the docs.
 
I did
For example, I need shared memory
so I learned that multiprocessing.manager() can do it
sounds great, doesn't it?
So after spending 3 hours preparing my program for that, I discovered that not all types can go in there as shared... only some types like list, dict, and some others...
Sorry but I'm getting kind of frustrated because this happened again and again, so I'm seeking advice/ideas
 
Write your high-performance code in C using the Python C API to release the GIL and use ctypes/cffi to call it from Python. Problem solved, you can do everything you want in C.
Python is not a high performance language. It was not designed to be.
 
Well, I could do that, but if I'm gonna go this way, I wanna make sure there's a good reason and my situation is hopeless. I'm learning python also along this journey :-)
 
12:17 AM
that is the good reason
the high performance you are looking for
 
Really? This kind of parallelism is already a good reason?
 
well you seem to be really frustrated with certain limitations you have reached in Python with what you are trying to achieve
and per davidism's suggestion, you can go the C route
and remember where Python came from...so it's not like all that Python code would go to the trash
 
I see your point. I'll keep that in mind as last resort! Hopefully I'll be able to do it the Python way. It's another thing to learn, isn't it?
 
sure
 
Plenty of high performance Python packages are written in C. numpy comes to mind.
It's not a last resort, it's a normal thing to do.
 
12:21 AM
Honestly if I would've known that I'd need C/C++, I would've started the project with C/C++... I thought this is a chance to learn GUI programming with Python with some intermediate performance needs...
Maybe I'm too paranoid about performance because that has always been a concern while I've been doing C/C++ programs
 
by grouping C/C++ like that...I don't think you understood what davidism was getting at...
 
Actually I used to write very high performance programs using C++ masquerading in C
I know what he means, but I combine C and C++ normally
 
then what's wrong with combining Python and C?
 
Nothing, except that I did C/C++ for 8 years, and I'm now learning something new :)
One question though: In such a scenario, should I just implement the functions inside my QThread class in C? or rewrite the whole QThread class in C?
 
QThread is already C (or C++, I don't know what QT is written in), PySide just wraps it.
 
12:27 AM
Actually that's weird... why is then limited by GIL?
Qt is written in C++ mainly
 
Because you're trying to execute Python code with it. As I said way earlier.
 
Oh, I see
That actually answers my question... then I should just implement my class calls in C
 
Thanks, this is helpful!
man... I just hope my boss is not going to kill me for spending a week on this :-)
 
what are you working on, out of curiosity?
 
12:31 AM
I'm a physicist mainly. This is a part of a project called GNOME
Global Network of Optical Magnetometers for Exotic physics
The idea is to acquire magnetic fields from all around the world to study and study their correlations to detect new particles in the universe
 
cool!
 
We're synchronizing acquisition from all stations around the world using GPS
so someone created an acquisition box with GPS in it, and I created the software to acquire data from it
Thanks :)
We're hoping to make a discovery as big as gravitational waves!
 
@TheQuantumPhysicist - back to shared memory, have you looked at shared memory numpy arrays? I'm not 100%sure the module is still maintained, but I've used it in the past. It's usually not the answer, but it certainly is to some problems!
 
@TheQuantumPhysicist Best of luck! Sounds like very interesting work!
 
Also, that sounds like neat stuff!
 
12:38 AM
Thanks, guys! :)
Actually never heard of shared numpy stuff before
I'll look into it!
 
Browsing the repo, it may be unmaintained now...
 
Actually I more want like sharing an arbitrary object! That would be great!
This is included in numpy still or unmaintained. Do you know?
Apparently some guy did this, right? It's not original numpy stuff
 
Well, if you need an arbitrary object to be mutable from different precesses, that's tough. Better to use explicit message passing
Sorry, on phone. Hard to type
Not it's not in standard numpy
 
Actually I don't even need real multiprocessing within QThread... all I need is that my calls become independent of my GUI
I'm happy with a pool with 1 thread
 
But I have used it quite a bit in the past. Sturla is a fairly big name on the scipy community
Ah, okay, that makes sense
 
12:44 AM
Really? So he's as reliable as numpy itself?
 
Obviously not, and the module is semi unmaintained these days
 
That's why I don't take code from people normally :)
I take it from organizations only for this reason... unless I want to maintain their code myself
Do you know pathos? I actually didn't use it for the same reason
It seems to be not very well supported in Windows
 
I've never used pathos, can't say one way or another
 
(yes, it's ridiculous that I'm using windows, I know, but that's what the people in my collaboration use)
 
Eh, most of the Python development I get to do these days is on Windows
 
12:47 AM
oh, really?
That's kind of relief :P
 
Yeah. I mostly maintain a bunch of c/c++/Fortran/Perl/tcl applications on Linux (rhel 5)
Si the option stuff is all windows, oddly enough
 
hehe, I see!
 
Big companies do things far more strangely than academia
:)
 
I do all my calculations on linux... funnily never had to maintain a GUI program on Linux ever
I can imagine... which is why I still program on Windows xD
I'm probably leaving academia next year
 
You'll miss it eventually... Or I did, anyway. Not saying it's the right choice either
 
12:50 AM
Why do you miss it?
 
Interesting people
Interesting work
 
How long did it take to start missing academia
 
Meh, I'm hopeless in academia... now I know it for sure
 
because I'm still not at all...it's been well over 10 years
 
I'm not that good with experiments, and I won't get a position with programming
 
12:51 AM
academia?
 
About 3 months. Also, don't be too sure about not getting a position focused on programming. They do exist, though it's more equivalent to a lab tech position
@Arunex - research at a university, etc
 
Well, if I would want to stay, I'd like to have a position as a scientist who does simulations all day
that's my ideal position
 
Oh. You use the term in place of studies/uni. I know for sure i'll miss it when i leave. I love learning this stuff
 
I love learning, but not the way it was taught
 
It's interesting and I love it... but I hate begging for funding all the time...
 
12:53 AM
@Arunex - more graduate work and our being a professor
Yeah, there is that
 
That was actually the main reason to leave academia...
funding...
 
That and that you eventually have to become a manager, more or less
 
So I had an agreement with my boss... I'll move to some industry position, but still maintain this GNOME project for the rest of my life ;)
 
Yea well... I hate the way it's taught too, but I did most studying online with tutorials and stuff, but still had very qualified personnel for simple immediate answers to any questions
 
Heh! Good luck!
 
12:54 AM
Exactly! I was just gonna say that professors don't even do research
Thanks! :)
That's why I was saying... a permanent position as a scientist would be great
 
chat.stackoverflow.com/users/1317944/the-quantum-physicist luckily the costs for Universities here are no where near USA's rates.
 
but this is very, very rare
 
Some do, some don't. But yeah, funding and managing grad students :)
 
Universities in germany are free ;)
Yep!
Now I'm a postdoc, and I have to somehow do it
I'm obsessed with getting stuff done myself, but the number of my students is increasing
which again gets me into management most of the time
 
I cant wait to hit the real world of programmers.
 
12:57 AM
Not to rare. At least for geology, pure research positions exist, particularly at the national labs or usgs. They're just hard to get
Students as a postdoc, eh?
 
@Arunex Tell me how you imagine that world :D
 
I don't envy you!
 
Geology... I actually had to take that module in my Computer science course for enough credits.
 
Yep! I have 2 bachelor students, and 1 PhD and and a master student who just told me 2 days ago he's gonna come to the group
 
12:58 AM
Damn! Lots of students!
 
I'm sorry, what's epic?
 
@Arunex - geology is fun! :) I hope we converted you!
 
hahah @JoeKington :D
 
@JoeKington Nope. Not even close. My brother is a geologist. But I fell in love with programming
 
Ah, well, can't win them all!
 
1:00 AM
I'm in love with computers since I was 5... but I still went to physics... and now I'm mostly a programmer :P
I should've known it wouldn't ever have worked xD
 
I only discovered the wonderful world of programming 2 years ago.
 
Eh, I got my first computer at 25, went into geology to avoid a desk job, and still wound up as a programmer! :p
 
The first program I wrote was when I was 13 years old
it was Visual Basic 6.0 xD
25? WoW!
How old are you now @JoeKington?
 
Actually, I started playing around in dos on the school computers at 23
Just never owned a computer until I was working in my PhD
35
Wait, 34
Either way
 
1:03 AM
WoW... That's kind of impressive that you never seen a computer until then
 
Also, 23 should be 13
 
Makes more sense! :P
 
Typing on a phone is difficult it seems
 
I hate chatting on phones!
Very used to keyboards
 
Well, I did grow up in a very backwoods area... Grade school had a few computers, but high school didn't
Yeah, me too... Airports... And no laptop
 
1:05 AM
Where are you from?
 
Tennessee, originally.
45, minute drive to a stop light
 
Oh, wow!
I see!
 
Our town was very backward too. in fact, the school still uses CRT screens
 
I like cities a lot... don't like low-population places
LoL!
Seriously?!
 
Eh, if you grow up in one, cities seem strange
 
1:07 AM
I understand! I grew up in Abu Dhabi, Emirates
It's relatively a big city
 
That's a bustling city!
 
Is it? Really?
 
I'm in the oil industry these days. Never been to the UAE, but every one I know goes there often
 
I remember spending my teenage days on computers :P
Does your geology major help with working with oil?
 
The stories I hear make it seem pretty big and growing like crazy
Yeah
 
1:09 AM
Actually it's true... but back in my days it wasn't that crazy
 
The past of things I'm in more or less requires a PhD in geology/geophysics
 
It started becoming crazy about 12 years ago
I see!
 
I always used to think stuff like programming was far beyond me. and stuff like "latest graphics technology" would have nothing to do with me because I'd never be able to keep up anyway. I can't believe I was that dumb to think that
 
Fair enough! Oil towns all over took off about then
 
People always fear new thigns :)
@Arunex I used to feel the same about microcontrollers, until I programmed one with C :)
 
1:11 AM
@TheQuantumPhysicist I just thought it was super complex and made no sense. I didn't think it would actually be easily read.
 
@JoeKington I decided to become a quant... I just hope this will be close enough to my knowledge
 
@Arunex - Free things are as complicated as they seem at first.... And the ones that really are seem simple at first glance. Never be afraid to dive in and learn!
 
@Arunex It's just about getting used to it!
@JoeKington +1
 
S/free/few
Quant seems like fun stuff! You should talk to DSM
 
1:13 AM
I'm just glad I might be able to make it to the front of the industry at some stage
 
He's another physisist turned quant
 
@Arunex Keep it up, and that would be really easy!
@JoeKington Oh, he's a person?
 
SO user here. On chat a fair amount.
 
Where does he live?
 
Can't link to his profile on the phone easily
 
1:14 AM
I found it here
 
Toronto, I think
 
Oh, I see!
 
yeah
 
It would be interesting to talk to him!
 
He's a great guy!
 
You'll see him around here
 
fellow Canadian :)
 
Okay... Gotta catch a flight. Great talking to you folks! Cabbage!
 
@DSM Hi DSM, nice to meet you. People told me you're a quant, and I'd love to talk to you some time about it because I wanna become one in less than a year :)
@JoeKington Have a nice trip! :)
 
1:16 AM
take care Joe
 
See you later guys... gotta go sleep :)
 
cheers
 
hmmm... 3:19AM... I should go sleep now too.
 
9:19PM here
 
Anyone here that can help a beginner out on a problem?
 
1:26 AM
ask your question, if anyone wants/can answer they will.
also keep note that this is a pretty quiet time in the chat.
There aren't a lot of people online right now
 
I'm trying to figure out how to code something to the effect of "If there is any True value in row R, return True
row_conflict(board,r): Given a board and an integer r indicating a row index, check and return
True if a queen is already placed in row r; return False otherwise.
o Assume: board is a list of lists of Booleans; board is square; r is an integer.
o Hint: Remember, the board is zero-indexed, and negative indexes are not to be used.
o row_conflict([[True,False],[False,False]],0) → True
o row_conflict([[True,False],[False,False]],1) → False
 
You want to use a function like any
 
That's the problem we haven't learned about that function so we cannot use it
 
have you tried coding this yet?
 
My best take is somethihng like this
def row_conflict(board,r):
for r in board:
if any row ==True
but we're not only to use any
 
1:34 AM
FYI that's not how you use any in that context, either.
don't know if you are showing just a rough sample. But that's not valid.
 
Yes I know its not valid all I know for this code is I want something to the effect of If there is any True value in row R, return True
 
you're looking for something like "if row contains true"?
 
yes how would I say that in python code?
wait is 'contains' itself a implemented function just like 'any'?
 
if true in row:
or wait. Damn java is forcing me to think of if(row.contains(true))
 
i dont think if true in row: works tho because there could be more than 1 value in a row?
like these examples row_conflict([[True,False],[False,False]],0) → True row_conflict([[True,False],[False,False]],1) → False
 
1:39 AM
here is a simple hint, you should be able to figure out how to apply it to your data structure:
a = [False, True, False, False, False]

if True in a:
    print("True exists...yay")
 
YEa, It's normally for strings. you could have stuff like
if bla in bladiblabla
that would return true. My python is a bit rusty though.
@idjaw oh wait... then I was right?
 
I didn't actually notice you said that earlier hehe
but yes
 
oh.. that seems a lot simpler, Arunex said the same thing but having visual list helps a lot, thanks!
 
@idjaw heh. I remember this stuff a bit :)
what!? how was his more useful :O???
nvm. I prefer simple examples too :D
 
def row_conflict(board,r):
for row in board:
if True in r:
return True
else:
return False
getting an error for the line "if true in r" saying "int" is not iterable
any fix?
 
1:45 AM
properly format your code
highlight it and hit ctrl-k
but it has to be in its own message
 
for row in board:
if True in r: //r????
Where does "r" come in?
dont you mean
if true in row:
Actually yes. I'm very sure that's your error. r is some integer value, and row is what actually contains the list of booleans
@Jessica I forgot to tag you
 
2:04 AM
@Arunex r is the row we're testing for to see if there's a true value in the board
def row_conflict(board,r)
 
your code does not make much sense. You are passing board and r, but then you iterate for row in board and check r?
 
@Jessica the row that contains all the boolean values, or just an int to indicate which row you want?
 
@Arunex just the int as indication
 
exactly. so if r is 5, then
if True in r:
means you're trying to look for a True in the number 5
@Jessica what you want to do is get row number 5, which will have all the true/false values, then you can check if True is in the list row[5].
 
def row_conflict(board,r):
	for r in board:
		if True in row:
			return True
		else:
			return False
this gets me error saying row isnt defined
 
2:10 AM
Because row is not defined!
look at your code, you never defined row
You need to revise what it is you are exactly passing to your method. Think over how you should be defining your method, and realize what you are getting when you iterate over your board.
 
@Jessica yea, because now you haven't declared it. Lol. I can see you're just starting out programming right? I'll try answer better from now on
 
Here is a suggestion.
def row_conflict(board)
 
say something like:
row = board[r]
So that you actually get the list of the row you want
 
now just iterate over board, and you should have each row when iterating.
 
row_conflict([[True,False],[False,False]],1)

def row_conflict(board,r): // r=1
row = board[r] // you want to get list number 1, that would then be [False,False]
if True in row:
return True
else:
return False
 
2:18 AM
was that it all along?
well, OK then.
 
Cabbage
 
PM!
actually. You mind giving me your opinion on something?
 
@idjaw I'm pretty sure jessica is starting out programming. So she needs actual code
 
Not a problem, idjaw!
 
You mind reading the events in the comments that occurred here?
Yes, not a good quality question. New user, and I feel like a better approach could have been taken because they are a new user.
 
2:21 AM
@Arunex Good call. IIRC, I saw an SO question from Jessica a day or two ago that had similar confusion between a sublist in a list of lists and its index.
 
@Arunex Agreed. I took a bit of a minimal info approach to get her to think about the problem more. But, yes...as I am a visual person as well. Code samples would help more.
 
@idjaw I used to abosuletely hate it when I was just starting to learn to code (2 years ago) and when ever i asked a question, people gave me the longest explanations or the approach I'd need to understand to get to the answer whereas all I wanted was a direct answer or example. Seriously, if I asked "how do i change string to int?" became the most complex essay as an answer talking about parsing and type casting from one object type to another.
As a beginner, that was all just nonsense to me and made it worse. All I wanted was "Integer.parseInt(num1)".
 
Yeah, I totally get it. Sometimes I take the approach to help direct the thought process to possibly finding an easier solution if the current path is leading to something more complex.
But...yes, also I sometimes lose sight of how new some material is to people and that thought process sometimes does not come as naturally
 
Cabbage :-)
 
cbg \0
 
2:33 AM
@idjaw I want those kinds of answers now because i actually understand the stuff.
 
@idjaw The poor kid is obviously a bit confused. And although the question isn't good, it's a damn sight better than heaps of newbie questions. It's has an easy-to-read chunk of code. Sure, a clear problem statement and a traceback would have been good, but anyone capable of helping can easily tell what the problem is.
 
@PM2Ring I could tell from the code that there was confusion, because they clearly used open correctly in the code once. Accidentally used a string of the file name variable.
The other side of this all, is I find that for such high rep, I would expect the individual who triggered the OP to get mad should have had the experience behind them to realize this is a new user, and either silently close vote to avoid the "mocking', or give them the generic "welcome to SO" spiel
I answered because I figured, they were just confused, and I'd help them get on their way.
 
I learn by example. I think it's better to show sample code and explain how it works. Because someone designed it, so the mechanics of the design need to be explained how they would be implemented.
 
IMHO, zondo should've been more explicit in his request for a traceback. And Tigerhawk's initial comments could've been a little more diplomatic. FWIW, he used to hang out here a lot, until he was told to stop complaining so much about crap questions.
 
yes, I remember this very well actually
I have my own issues with each of those contributors. Which is also why that entire exchange really bothered me
I see OP accepted my answer, so hopefully they also read my comments
 
2:41 AM
@Arunex I'm reasonably good at abstract thought, but I like to see tangible examples, not just abstract descriptions. IMHO, it makes it easier for the brain to digest and retain the info, and examples can help clear up ambiguities. A common complaint about the official Python docs is that they don't contain enough examples. But hopefully the SO Documentation initiative will rectify that situation.
 
@PM2Ring My kind of tutorials that I love are ones like this stavros.io/tutorials/python which has a complete overview of everything and simple enough to understand. then once I have the basic idea, I would then know what to look for when I want a more in depth explanation
 
@Arunex That looks good.
 
@idjaw Let's hope.
You might want to mention in your answer that those import statements are also unnecessary. Sure, he may want to use them eventually, but they don't belong in a MCVE.
He's obviously still at the "magic incantation" stage of coding. But with gentle guidance he may begin to understand what he's doing and not turn into a cargo-cult coder.
@davidism On hold
 
@PM2Ring done! :) And thanks for looking in to that question for me. As I'm contributing more, it is starting to really bug me when new users have such a horrible first experience and say they don't want to come back
 
2:50 AM
@Arunex your code works with 2 exceptions, when r is negative and when r is out of range like these: row_conflict([[True,False],[False,False]],-2) → False
o row_conflict([[True,False],[False,False]],5) → False # index out of bound
 
cabbage
nice job answering that question @idjaw
 
@Arunex can you implement that in your code? I've tried if r<0 return False but that didnt work
 
thanks @Jonathan
 
it was a reminder how there truly are many levels to programming and even more so many levels to understanding some of the concepts starting out.
 
@TheQuantumPhysicist I have a suggestion: when investigating various options, don't immediately implement them in your main project. Instead, create a small test program so you can quickly test the variations and see if it works how you expect.
 
2:53 AM
yea, that would just be exception handling. So you want to only run the code
if r>=0 && r<len(board) // len is used to get the length of a list
 
@Arunex yea but where would I put that in the code?
def row_conflict(board,r):
	row=board[r]
	if r>=0 and r<len(board):
	for r in board:
		if True in row:
			return True
		else:
			return False
@Arunex that doesnt work for sure :3
 
def row_conflict(board,r):
if r>=0 && r<len(board)
//code here
else
return False
 
Arunex, please indent your code correctly!
 
@Jessica Ha ha, and you can get rid of that for loop. it's uselessly adding extra stuff that does nothing (if that makes sense)
@PM2Ring I swear I indented it correctly when I typed it :O
Why does that ctrl+k thing not work? :/
 
You need to click the "fixed font" button, or hit Ctrl-k on your keyboard.
Try selecting the text first, eg with Ctrl-a. Then hit Ctrl-k
 
3:02 AM
@PM2Ring all it does is shift all my code up by like 1 or 2 spaces
 
exactly
that's it :)
just make sure the code is in its own post
 
I think you guys are lying to me -.-
 
it's not rocket science
edit your post, press ctrl+k, submit
 
Also, you keep leaving the colon off the end of your if statement.
 
3:06 AM
select all the text. press ctrl+k. Everything indents by like 1 space. So use the fixed font button instead and it literally did the exact same thing...
 
@Jessica Try this:
def row_conflict(board,r):
    if r>=0 and r<len(board):
        return True in board[r]
    return False
 
def row_conflict(board,r):
    if r>=0 and r<len(board):
        return True in board[r]
    return False
 
\0/
 
Well that worked. Why didn't it do it before?
 
it wasn't in its own message
 
3:07 AM
it was. both times.
 
well...it works now. Let's move on :D
 
@Jessica: But really, it would be better if row_conflict can assume that r is valid. So the code that calls row_conflict should make sure it never calls row_conflict with a bad r.
rbrb
 
Oh wait. it doesn't auto indent?
 
code works, can someone explain what "return True in board[r]" is doing?
 
It's returning whether the value True is in the value at index r of board.
 
3:12 AM
@Jessica (True in board) is either True or False. so if board contains True, then "True in board" is basically just the same as "True". So "return X" is you saying return what ever value "True in board" is.
 
3:45 AM
@Jessica It does the same as this:
    if True in board[r]:
        return True
    else:
        return False
 
ergh, I really hate getting downvotes with no explanation it really freakin' bugs me...a lot
 
There's a bit of that happening lately. Some poor kid just got 5 downvotes on a simple typo question. THat one I just linked above. :)
 

« first day (1991 days earlier)      last day (2948 days later) »