« first day (2410 days earlier)      last day (2530 days later) » 

12:37 AM
Does python skip loop iterations if the values aren't used and all the called functions make no external impact (like editing global vars or communicated with the system)? Its either that, or python list assignments are mindboggligly slow. Removing the list assignement from this nested for loop made it run thousands of times faster, taking about a second instead of minutes.
 
12:48 AM
@GiantCowFilms We need to see a MCVE. But if you are rebuilding the whole list inside a nested loop that is slow and there may be a better way.
 
1:32 AM
@PM2Ring Okay, here it is:
# bpy is an API I'm working with. I'm not sure if this API could have an impact on the problem
image = bpy.data.images[tex_name]

data = image.pixels
# pth and ptw are the image dimemions. It is four channels.
for h in range(0,pth):
        for w in range(0,ptw):
	    #note, n is actually defined by a function call. I have verified that is not the cause of the slowdown. Solutions that assume n is the same for all values will not be helpful.
            n = 1.0
            for s in range(0,3):
		#swapping this line for pass makes the program run instantly, instead of taking minutes.
 
Cbg
@GiantCowFilms a pastebin would be better
@GiantCowFilms also note that this not a MCVE because it has many missing declarations
Err.... accessing variable before assignment, I mean. Whatever we call that in python
 
@Code-Apprentice I see only two...
one can be fixed by adding this line: pth=ptw = 256 at the top
the other one - bpy - would require ALOT of steps to setup, since its the api for accessing another piece of software (blender 3D)
changing data = image.pixels to data = [1.0]*(4*ptw*pth) fixed the performance issues. How does that make sense. If image.pixels was a list of 1.0 with those dimentions (which it was), how on earth does initializing it make a difference?
 
1:55 AM
Are those variable even necessary for the question?
Initializing makes a huge difference because otherwise I get errors when I copy and paste your code. Those errors prevent me from helping you.
@GiantCowFilms since you are asking a question, your primary job is to make it as easy as possible for others to help you
 
@Code-Apprentice I'm saying the errors appear to be rooted in the API I'm using.
 
The more work we have to do to understand your question, the less likely we are to take the effort to help you
 
@Code-Apprentice, if you read the comments, it should make sense why its not working.
@Code-Apprentice I see
 
@GiantCowFilms what errors?
 
Sorry, wrong word. Slowdowns
 
2:00 AM
@GiantCowFilms what comments?
 
Those in the code
 
I did not take much time to read them. I am on my phone and the comments run of the screen.
Try making a code example that anyone can run. Include import statements as necessary and even explain what API you are using
 
 
2 hours later…
3:50 AM
@GiantCowFilms data = [1.0]*(4*ptw*pth) essentially builds the list at C speed, so it's much faster than setting items one by one with Python loops.
 
@PM2Ring That was not the slow line.
It was the line in the loop. But the line in the loop ran faster if I used that declaration, instead of image.pixels
 
But you said it fixed the performance issues.
 
Yes, changing that fixed the performance issue later in the code.
 
I'm on my phone so I can only offer limited help. But I suggest you take a look at Numpy, it's generally much faster at array processing than pure Python. But it depends on what you're doing - if you can vectorize your pixel modifications then Numpy can be quite fast, and if those operations can be done with standard Numpy operators or functions then it will be almost as fast as C.
 
 
3 hours later…
6:31 AM
Morning cbg
 
7:28 AM
I want a snake pet
 
7:40 AM
go to snakepet.stackexchange.com :)
 
@BillalBEGUERADJ it's a panda
 
cabbage-ning
 
are there any disadvantages to serving my static files through uwsgi versus nginx (which forwards the requests to uwsgi)?
 
@Mosho Yes, nginx is faster and does a lot more
91
A: node.js itself or nginx frontend for serving static files?

m33lkyI'll have to disagree with the answers here. While Node will do fine, nginx will most definitely be faster when configured correctly. nginx is implemented efficiently in C following a similar pattern (returning to a connection only when needed) with a tiny memory footprint. Moreover, it supports ...

 
mmm
I'm dockerizing our app and each container has uwsgi in it, with static files
 
7:55 AM
in future, if you get lots of load, witll also provide load balancing
 
sharing each static folder within each container with the nginx container would be a mess
 
you will need to change the directory of the static files
setup nginx instance(s) in front
 
but each uwsgi instance has different static files
 
how is that possible?
 
4 different domains, serving 4 different versions of the same app
 
7:57 AM
sure, then you will have 4 different directories and serve from the correct stuff from nginx confgi
 
they are not different directories
well, they are
but they are each withing a separate docker container
 
you will have to change that
you don't need static files with uwsgi
 
that container (which contains the app) manifests the static assets
when I build the image
I don't see what I can do differently here :\
how about having nginx cache everything
 
I don't see how that would help
 
after the cache is filled, requests for those files won't reach the uwsgi containers anymore
nginx would serve them from the cache
 
8:03 AM
yeah maybe that could work
but I am not sure
do you have performance issues?
 
not at all
with the current (non-docker) setup
and I haven't deployed the docker containers yet
 
do you expect massive load increase?
 
I'm not sure, we haven't had any users really until now
so there is going to be an increase
not sure about the scale
 
the good thing about nginx is that, if you get load, you can easily increase the number of servers of your app and nginx will load balane
We haven't used docker yet, and we are handling 10k requests per second
 
yeah we are not going to have that much for sure
 
8:46 AM
Mornin'
 
Wow, must be a new personal record for me: an accept on an answer 3.5 years old.
 
 
2 hours later…
 
1 hour later…
11:52 AM
university grading is ridiculous
for my final project, I took a challenging problem. Designed an algorithm, wrote a network simulator, did simulation and got B+ because "I didn't complete initial goals", which included comparing with other algorithms but I didn't have time. The other team set up a simple network, simulated DNS attack and got A+
 
cbg
@khajvah that's not really "university grading", that's "grading". It depends on the specific human instance who gets to judge your work.
 
the same people judged everybody
and when I wrote an email, they are like "you didn't include raw logs and you didn't finish the initial goals"
 
yes, but if they are asshats, then this happens
at the same university, only one course away, you could've run into someone helpful and fair
like me :P
 
I don't even know how they graded 10 final projects in 2 days
that looks impossible
 
yes.
if they don't read what's in the work, the shortest short-cut is skimming the "results" chapter
"ah, no comparison"
 
12:06 PM
@khajvah Same here (and everywhere): I built a complex database system and did “proper research”; someone else built a simple website and got the better grade.
 
was your "proper research" shiny and webscale?
 
so there were 21 projects
they somehow graded them all in 2 days
 
guaranteed to result in a half-assed job
 
12:36 PM
if you're seriously interested in having your grade adjusted I would recommend talking to the professor in person, not firing off emails
 
I assume he just inquired as to the reason of the B+
 
i don't really care about the grade so I won't waste time on pointless meetings
 
the conversation suggests otherwise
 
@excaza I mean I don't really care about the letter. I just find it unfair that simple trivial projects earn more than my non-trivial project.
 
then do something about it?
 
12:41 PM
I wrote an email. That's the most I will do
 
lol, ok
 
general sense of social injustice
 
1:03 PM
morning everyone
 
cbg
 
cbg
Maybe non-trivial project earned B+ because it did not do what was needed? 50 page thesis on the Fall of Rome, while brilliant, does not an autobiographical sketch of Caligula make.
 
(cleaning up old browser tabs of mine)
 
@poke don't foget to cv again
 
@toonarmycaptain it was their own suggested project
 
1:10 PM
I really wish iOS's PIP feature actually worked on popular sites :\ I would think netflix, youtube, and amazon prime would be a minimum
 
@Andras I can’t… :( “You voted to close this question May 2 at 12:31”
 
hmm
I was under the impression that aged-away votes can be cast again
did you refresh the tab?
 
yup
It says so in the close vote popup
 
:(
300+ rep with a question like that, makes me want to talk a closer look
 
@khajvah fair enough it just sounds like when you say "you didn't finish the initial goals" it makes it sound like you didn't really complete the assignment. Something I did a lot in college...damn fine assignment...didn't answer question set.
@poke I would but can't vote yet
 
1:17 PM
That's absolute cack @khajvah :(
 
(*take a closer look :| )
 
I thought Uni was okay with people overreaching, as long as they recognised it, and (correctly) identified where it went wrong
 
1:40 PM
the serial upvotes I got weren't caught by the script
I thought that 7 in a row would surely trip the system
 
Can someone nudge me into the right direction? If I understand correctly, the loop which creates clen is just adding 1 to all elements and finding max(clen.values()) of this is sort of... trivial?
 
hey have any of you guys used codeacy?
 
@RomanLuštrik it looks like it's looking for the element with the most occurences in lens
with an additional test that there's a unique length that is most frequent, unless I'm mistaken
 
@AndrasDeak Then I may be misunderstanding what is going on in line clen.get(i,0).
 
1:55 PM
clen[i] if i in clen else 0
 
When I do a small test, I get:
clen = {}

print("print empty")
print(clen)
for i in [3, 2, 5, 1]:
    clen[i] = clen.get(i, 0) + 1

print("print filled")
print(clen)
print empty
{}
print filled
{3: 1, 2: 1, 5: 1, 1: 1}

Process finished with exit code 0
 
because there are no multiple occurences
you're testing with a unique vector
try [3,2,4,2,5,2,2]
 
DSM
Victoria Day morning cabbage for all.
 
cbg
 
Whoever wrote that code should use collections.Counter instead
 
1:57 PM
@AndrasDeak Makes sense, thank you.
 
no worries
 
No I get it. It tries to fetch this element if already existing and adding +1.
 
@Kevin is there a simpler way than Counter(lens).most_common(1)[0][0]?
 
That's a very longwinded way of what we do in R using table(x). :)
 
I did that myself, but didn't suggest that because that's far from profound
 
1:57 PM
@Andras There's statistics.mode but it requires that there is exactly one most common
Unlike most_common, which will happily choose semi-arbitrarily if there's a tie
 
yup
hmm, but then statistics.mode is exactly what is needed here
 
Also it's 3.X only
 
perfect
 
"If I can make just one 2.7 user as unhappy as if they were standing in the rain and a car came by and splashed them with brackish puddle water, then I'll have made a difference"
 
2:06 PM
Walking through town all alone on Christmas eve and peering in through the front window to see a family settling in for a lovingly crafted dinner is also an acceptable level of misery
 
and that code is indeed python2...
 
2:46 PM
Hi all, I tried to make that question more "questionesque", I hope it's getting more usable: stackoverflow.com/q/44085554/7051394
(also, I'm still not looking for free rep, I just want to genuinely contribute)
 
Hi what can I do if I found a bug in built-in python function
It is described here
 
first make sure that you found a bug :)
 
Check it out
 
what builtin and what bug?
 
I wager 23 quatloos that it involves floats
 
DSM
2:57 PM
I wager it involves null bytes.
 
I wager that a link is missing
 
I only accept if you promise you didn't already check Kostya's profile to see if he asked any questions recently and one of them involved null bytes.
 
Yes, input function should not cut prompt by NULL byte
 
4
Q: Python bug: null byte in input prompt

Kostya CholakI've found that input('some\x00 text') will prompt for some instead of some text. From sources, I've figured out that this function uses C function PyOS_Readline, which ignores everything in prompt after NULL byte. From PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, const char *promp...

I guess I may as well post it since nobody else did
 
thank you
any thoughts about this?
 
DSM
3:00 PM
@KostyaCholak: go to http://bugs.python.org/ and search to see if it's been reported before. If so, mention that you came across it yourself. If not, open a new one.
 
I expect them to acknowledge that it's a bug, but say something like "... But it occurs in such a rare case that it's pretty far down our priority list to fix"
 
kevined, sort of
 
DSM
There might be a reason for the behaviour you're not seeing (some edge case on some architecture for which this is the simplest workaround). That said, I think they should probably be calling print on Python's side and using the system readline with an empty prompt.
 
They might just accept a pull request...
 
DSM
3:02 PM
@Kevin: I remembered the question from earlier today.. do I get half points? ;-)
 
Hmm, fine. 11.5 quatloos have been credited to your account.
 
DSM
3:13 PM
At some point I'm going to have to redeem all those quatloos.
 
oh, I got some too
Kostya posted his bug report
experienced peeps: should it perhaps be a bit more verbose? bugs.python.org/issue30431
then again the title is pretty clear
 
DSM
True, but I'd have basically put the diagnosis from the Q in the bug report.
 
I think I prefer "truncates at null byte" rather than "truncates by null byte"
 
DSM
#prepositionshaming
 
3:44 PM
when I want to switch office windows with ctrl+w
I should find a plugin that lets me write docx files using vim
 
DSM
4:10 PM
"I was thinking that something along the lines of def logic(exp, lst) would be the solution" <- I'm not sure that's the standard use of the word "solution".
 
Many solutions to programming problems do contain a def, but pointing this out is not particularly helpful
"This problem could be solved by solving this problem"
 
DSM
Like people who say "my code so far is def solve_problem(): open("filename")".
 
Devil's advocate: there are rare problems where suggesting a function signature will sufficiently cause the rest of the implementation to fall neatly into place
 
4:26 PM
dude
 
DSM
That's indeed a diabolical suggestion, because I can't deny that it's true but it's deeply misleading in this context.
 
I'm not sure who I prefer: OPs that show no effort at all, or OPs that try to show the absolute minimum amount of effort possible.
In the former case there's the one in a hundred chance where you ask for an MCVE and they say "oh, I didn't know you'd want that" and they actually give it to you
In the latter case it's a near certainty that open("filename") is all they ever wrote up to that point
 
4:42 PM
Paradoxically, if you put in the minimum amount of effort needed to get an answer, all the potential answerers will notice you put in the minimum amount of effort needed to get an answer, and they won't give you an answer.
It's like trying to find the smallest number greater than zero.
(No points for suggesting 0.00...001)
 
practicing with lists now in python. Do you use for loops for list the same as in java?
 
Lists are often iterated over using for loops, yes. If that's what you're asking.
 
ok
 
If you're asking "is the syntax for iterating over the elements of a list the same in Python and Java?", I'm pretty sure it's not the same.
 
I didn't believe so
I'm just practicing with a made up list now doing stuff
 
5:04 PM
recbg
@Kevin I'm afraid that's not true
it can be made mostly true if we account for some delay during which answers get downvoted and peer-pressured into oblivion
 
>>> re.findall(r"(\d+, )", "4, 8, 15, 16, 23, 42")
['4, ', '8, ', '15, ', '16, ', '23, ']
>>> re.findall(r"(\d+, )+", "4, 8, 15, 16, 23, 42")
['23, ']
I find this second result unusual.
I expected to get ['4, 8, 15, 16, 23, ']
>>> re.search(r"(\d+, )+", "4, 8, 15, 16, 23, 42")
<_sre.SRE_Match object; span=(0, 18), match='4, 8, 15, 16, 23, '>
Extra curious.
 
Hi guys
I'm trying to download files using this script

        with open(get_filename(), 'wb') as f:
            for chunk in self.response.iter_content(chunk_size=1024):
                if chunk:
                    start_time = time.time()
                    f.write(chunk)
                    end_time=time.time()
                    eta= round(float(end_time-start_time), 4)
                    filesize+=len(chunk)
                    speed= (len(chunk)/eta)
                    # ************************
 
5:20 PM
ok.
 
I am trying to calculate the speed but this is not working as its giving ZeroDivisionError
 
>>> re.findall(r"^(\d+, )+", "4, 8, 15, 16, 23, 42")
['23, ']
ummm....
what
or is this one of those "you think you know what re.findall does" moments?
 
Hang on, does findall do anything with capturing groups? Maybe I should mark them as noncapturing. What's the syntax for that again...
 
escaped parens?
no
 
eta is rounding up to zero and giving the ZeroDivisionError I think
 
5:23 PM
>>> re.findall(r"(?:\d+, )+", "4, 8, 15, 16, 23, 42")
['4, 8, 15, 16, 23, ']
This looks better.
 
but then why does it match with ^?
or does it return the last capturing group?
 
It matches the complete string from 4 to 23, but only returns the final digit sequence captured
 
> re.findall(pattern, string, flags=0)

Return all non-overlapping matches of pattern in string, as a list of strings. The string is scanned left-to-right, and matches are returned in the order found. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result unless they touch the beginning of another match.
I don't see anything relevant there...do you?
 
I learned the other day that you will only ever get back as many groups as you have literal capture parens. a pattern like (whatever)+ will never give you more than one group, for instance
Despite the pattern appearing to read "one or more capturing groups that match whatever"
This is true outside of findall as well:
>>> re.search(r"(\d+, )+", "4, 8, 15, 16, 23, 42")
<_sre.SRE_Match object; span=(0, 18), match='4, 8, 15, 16, 23, '>
>>> re.search(r"(\d+, )+", "4, 8, 15, 16, 23, 42").groups()
('23, ',)
@AmitSingh Ok, how about speed= (len(chunk)/eta) if eta else float("inf")
 
I think Perl 6 made major improvements on that front, not that it's likely anyone else will ever pick them up.
 
5:45 PM
Hey thanks. Got it working. But getting speed of around 400 mbps. I think this is giving me the the write speed of my hard disk. My internet is not this fast.
 
Yeah, you aren't timing the network operation at all.
Just the time it takes for f.write to complete.
 
that's write
 
You need something like:
start_time = time.time()
with open(get_filename(), 'wb') as f:
    for chunk in self.response.iter_content(chunk_size=1024):
        if chunk:
            f.write(chunk)
            end_time=time.time()
            eta= round(float(end_time-start_time), 4)
            filesize+=len(chunk)
            speed= (len(chunk)/eta)
            # ************************
            sys.stdout.write(str(downloaded)+'      '+str(speed) + '        \r')
            sys.stdout.flush()
            # ************************
If you also want to count the time taken to iterate through self.response each time
 
Is anyone here interested in discussing theories behind compilers, interpreters and programming languages?
 
cbg everybody
 
5:54 PM
Things like scanning, parsing, etc, and the different algorithms to achieve those phases of the compilation of a programming language
 
any of you familiar with SQLAlchemy?
 
I wrote a scanner/parser/interpreter once. You just need to read wikipedia articles for ten hours.
en.wikipedia.org/wiki/LR_parser is the important one.
 
We could also discuss IRs (and optimizations) and code-generation in the case of compilation.
@Kevin It depends on what you mean by important one. Sometimes it's easier to implement a recursive descent parser, if your grammar is simple enough, not ambiguous and not left recursive.
Anyway, we could already be discussing this in a chat I created for that purpose.

 Compilers, Interpreters and Programmi

A chat room for cs.stackexchange.com to discuss concepts and a...
;)
 
6:24 PM
@Kevin the start_time is not changing with each iteration, only the end time is.
 
You've got start_time = end_time at the end of the loop, right?
 
Oh! didn't thought about that. Thanks.
 
6:56 PM
@Jfach you know what cbg is but you may want to reread the room rules :)
 
7:30 PM
Does anyone know some good physical books for intermediate python programmers.
 
The physical version of whatever ebook you were reading?
 
I am not currently reading any ebook.
And if I did, I am almost surden that it wouldn't be available physical.
 
7:46 PM
@SebastianNielsen It depends what you mean by "intermediate", but Fluent Python is pretty good.
 
Thanks, I'll take a look.
Wow, the reviews are all so positive.
Zero it seems like it only is available as an ebook unfortunately. :(
 
Says "Print $49.99" on the right of that page for me (though I bought it as an ebook).
 
the fact that you can buy a paperback on ebay suggests that there is, in fact, a printed form of the book
what I'd expect from O'Reilly
 
I am prepared to print out and post my PDF copy worldwide for US$500 as a last resort ;-)
 
DSM
8:35 PM
Sorry I wasn't here to intervene -- I'm deleting that entire conversation. Apologies for everyone who got caught up in the shift, I didn't want to select portions to keep and portions to move.
 
thank you
 
8:48 PM
Cheers
 
@DSM feel free to also delete my joke "$500" tweet if you like; my ability to do so has timed out. Also, apologies for my part in the nonsense.
 
don't be ridiculous
 
I demand the right to ridiculosity ;-P
 
*laughs manneristically*
 
DSM
.. manneristically?
 
8:52 PM
it must be a word, I just used it in a sentence
 
9:02 PM
I'm not sure... what?
 
So I just discovered I can "blank test" my inputs with simply
if var:
else:
@AndrasDeak do you mean "characteristically"?
This is exciting as it...saves time
:D
 
@toonarmycaptain no
 
@toonarmycaptain I mean "in a way that would be considered a mannerism"
 
There's maniacally, but that's not manneristic
 
9:07 PM
think George Takei laughing when he's looking all ( ͡° ͜ʖ ͡°)
 
@AndrasDeak as far as I learnt, if someone has a characteristic laugh, it would be considered one of their mannerisms, possibly rather unique to them
but that was the bell, and it is time for me to fly
but not on the A380
 
rhubarb
 
...yet
lettuce all
 
perhaps there's a cultural difference between what you and we call a mannerism
 
Not flight time for me yet. About 20 minutes or so I think
 
DSM
9:13 PM
Oh, is PyCon over?
 
Sprints are going. Davidism is there for that.
But I couldn't stay for that, sadly
 
Next two years are in Cleveland btw
 
That's really more of a marathon than a sprint.
 
DSM
I think I need to buy a new external hard drive. My main backup drive has its file system slightly corrupted, which wouldn't be the worst thing except I don't have anything else large enough to transfer its files onto while I reformat. :-/
 
9:24 PM
is it possible to show/hide the console AFTER launching a tkinter GUI? I know it can be hidden from the start but i'd like to bring it up later to see some output if needed.
hard to search for a solution because everything on google points to people saying to use pyinstaller and other apps to hide from the sttart
 
@DSM teh cloud *waves hands around*
@sidnical try "toggle console"
(if you haven't already)
 
@DSM For $500, I am prepared to print out hexdumps of any disk blocks you send me, then OCR and return them after you reformat.
 
DSM
@AndrasDeak: I thought about it, but several TB of sim output is a lot of data transfer.
@ZeroPiraeus: :-P
 
:DD
 
@DSM have you seen some of the cool NAS setups?
QNAP TS-251+
 
DSM
9:27 PM
I don't know what any of NAS or QNAP or TS-251+ mean.
 
NAS = network attached storage
 
network backup storage
 
it's a generalized concept of an external drive
 
yeah that^
 
I assume QNAP TS-251+ is a specific instance of a pre-made NAS system
 
9:28 PM
just setup to be accessed from everything on the network. The qnap stuff is nice because it comes with built in apache, sql, webcam monitoring apps, etc.
qnap= brand. the ts-251+ is a base-ish model.
 
DSM
The "network" here is my home notebook, so this seems like overkill.
 
if all you do is backup files then a new drive is probably best but if you have home cameras or do anything with web pages or databases it might be useful
but when your computer friends come over you can point at it and say "that does a bunch of cool stuff" :)
just throwing the idea out there
 
DSM
I appreciate the suggestions, especially given that I know very little about hardware.
 
@AndrasDeak "toggle" found some useful results
thanks
 
wim
10:11 PM
@DSM I recommend you a DS216j or similar. Synology's software is excellent.
 
@sidnical no worries
 

« first day (2410 days earlier)      last day (2530 days later) »