Click here to Skip to main content
14,391,319 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: python - tail stuck under the rocks? Pin
Nand3213-Jul-19 7:00
MemberNand3213-Jul-19 7:00 
AnswerRe: python - tail stuck under the rocks? Pin
OriginalGriff13-Jul-19 5:55
mveOriginalGriff13-Jul-19 5:55 
GeneralRe: python - tail stuck under the rocks? Pin
Richard MacCutchan13-Jul-19 7:25
mveRichard MacCutchan13-Jul-19 7:25 
GeneralRe: python - tail stuck under the rocks? Pin
OriginalGriff13-Jul-19 7:31
mveOriginalGriff13-Jul-19 7:31 
GeneralRe: python - tail stuck under the rocks? Pin
Richard MacCutchan13-Jul-19 7:51
mveRichard MacCutchan13-Jul-19 7:51 
GeneralRe: python - tail stuck under the rocks? Pin
Sander Rossel13-Jul-19 10:10
professionalSander Rossel13-Jul-19 10:10 
GeneralRe: python - tail stuck under the rocks? Pin
Fueled By Caffeine14-Jul-19 23:48
MemberFueled By Caffeine14-Jul-19 23:48 
GeneralRe: python - tail stuck under the rocks? Pin
Sander Rossel15-Jul-19 0:30
professionalSander Rossel15-Jul-19 0:30 
Fueled By Caffeine wrote:
var processedPerSecond = processedCount / elapsedTime * 1000;
Probably there, you get an int instead of a decimal?
However, changing var to decimal will still result in a wrong output as an int is silently cast to a decimal, but that doesn't change outcome of the divide operation.
The fix I think you're looking for is:
var processedPerSecond = (decimal)processedCount / elapsedTime * 1000;
Now here is a fun bug, which I've seen go wrong multiple times...
var query = databaseContext.SomeTable;
query = query.Where(x => x.SomeBoolLimitingTheResultFromThousandsToTens);
return query.ToList();
In this piece of code the query variable is of type IQueryable.
That means the Where that is executed is actually Queryable.Where(IQueryable, Expression).
The actual database call, with WHERE clause, is executed on the ToList method (or more precise, in the Enumerator).
Now someone comes and changes the code, the first line becomes var query = databaseContext.SomeTable.ToList();
Suddenly, the type of query has changed to IEnumerable!
The database query WITHOUT the WHERE clause is executed and Enumerable.Where(IEnumerable, Func) is executed to filter the collection in-memory.
You now get thousands of records instead of tens, while the in-memory Where is probably more expensive than the database WHERE.
All in all a nice performance hit...

That is actually the only bug I've ever encountered while working with var, and it's pretty specific.
And the only reason it goes wrong is because IQueryable and IEnumerable have pretty much the same extension methods, save for Expression and Func, but a Func can be implicitly cast to an Expression.
Fun times Smile | :)

JokeRe: python - tail stuck under the rocks? Pin
lopatir13-Jul-19 8:09
Memberlopatir13-Jul-19 8:09 
GeneralRe: python - tail stuck under the rocks? Pin
OriginalGriff13-Jul-19 8:56
mveOriginalGriff13-Jul-19 8:56 
GeneralRe: python - tail stuck under the rocks? Pin
David O'Neil13-Jul-19 9:12
professionalDavid O'Neil13-Jul-19 9:12 
GeneralRe: python - tail stuck under the rocks? Pin
OriginalGriff13-Jul-19 9:20
mveOriginalGriff13-Jul-19 9:20 
GeneralRe: python - tail stuck under the rocks? Pin
David O'Neil13-Jul-19 12:31
professionalDavid O'Neil13-Jul-19 12:31 
GeneralRe: python - tail stuck under the rocks? Pin
Member 798912215-Jul-19 1:03
MemberMember 798912215-Jul-19 1:03 
GeneralRe: python - tail stuck under the rocks? Pin
DerekT-P17-Jul-19 0:53
professionalDerekT-P17-Jul-19 0:53 
GeneralRe: python - tail stuck under the rocks? Pin
Member 798912217-Jul-19 4:12
MemberMember 798912217-Jul-19 4:12 
GeneralRe: python - tail stuck under the rocks? Pin
GuyThiebaut14-Jul-19 0:39
professionalGuyThiebaut14-Jul-19 0:39 
GeneralRe: python - tail stuck under the rocks? Pin
Mike Winiberg14-Jul-19 21:55
professionalMike Winiberg14-Jul-19 21:55 
GeneralRe: python - tail stuck under the rocks? Pin
GuyThiebaut14-Jul-19 22:18
professionalGuyThiebaut14-Jul-19 22:18 
GeneralRe: python - tail stuck under the rocks? Pin
Mike Winiberg14-Jul-19 22:27
professionalMike Winiberg14-Jul-19 22:27 
GeneralRe: python - tail stuck under the rocks? Pin
r_hyde13-Jul-19 8:06
Memberr_hyde13-Jul-19 8:06 
GeneralRe: python - tail stuck under the rocks? Pin
Sander Rossel13-Jul-19 10:14
professionalSander Rossel13-Jul-19 10:14 
AnswerRe: python - tail stuck under the rocks? Pin
PIEBALDconsult13-Jul-19 6:07
professionalPIEBALDconsult13-Jul-19 6:07 
AnswerRe: python - tail stuck under the rocks? Pin
Sander Rossel13-Jul-19 10:19
professionalSander Rossel13-Jul-19 10:19 
AnswerRe: python - tail stuck under the rocks? Pin
GuyThiebaut13-Jul-19 21:07
professionalGuyThiebaut13-Jul-19 21:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.