Click here to Skip to main content
15,895,084 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 6:00
Nand3213-Jul-19 6:00 
AnswerRe: python - tail stuck under the rocks? Pin
OriginalGriff13-Jul-19 4:55
mveOriginalGriff13-Jul-19 4:55 
GeneralRe: python - tail stuck under the rocks? Pin
Richard MacCutchan13-Jul-19 6:25
mveRichard MacCutchan13-Jul-19 6:25 
GeneralRe: python - tail stuck under the rocks? PinPopular
OriginalGriff13-Jul-19 6:31
mveOriginalGriff13-Jul-19 6:31 
GeneralRe: python - tail stuck under the rocks? Pin
Richard MacCutchan13-Jul-19 6:51
mveRichard MacCutchan13-Jul-19 6:51 
GeneralRe: python - tail stuck under the rocks? Pin
Sander Rossel13-Jul-19 9:10
professionalSander Rossel13-Jul-19 9:10 
GeneralRe: python - tail stuck under the rocks? Pin
Fueled By Decaff14-Jul-19 22:48
Fueled By Decaff14-Jul-19 22:48 
GeneralRe: python - tail stuck under the rocks? Pin
Sander Rossel14-Jul-19 23:30
professionalSander Rossel14-Jul-19 23: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:
C#
var processedPerSecond = (decimal)processedCount / elapsedTime * 1000;
Now here is a fun bug, which I've seen go wrong multiple times...
C#
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 7:09
lopatir13-Jul-19 7:09 
GeneralRe: python - tail stuck under the rocks? Pin
OriginalGriff13-Jul-19 7:56
mveOriginalGriff13-Jul-19 7:56 
GeneralRe: python - tail stuck under the rocks? Pin
David O'Neil13-Jul-19 8:12
professionalDavid O'Neil13-Jul-19 8:12 
GeneralRe: python - tail stuck under the rocks? Pin
OriginalGriff13-Jul-19 8:20
mveOriginalGriff13-Jul-19 8:20 
GeneralRe: python - tail stuck under the rocks? Pin
David O'Neil13-Jul-19 11:31
professionalDavid O'Neil13-Jul-19 11:31 
GeneralRe: python - tail stuck under the rocks? Pin
kalberts15-Jul-19 0:03
kalberts15-Jul-19 0:03 
GeneralRe: python - tail stuck under the rocks? Pin
DerekT-P16-Jul-19 23:53
professionalDerekT-P16-Jul-19 23:53 
GeneralRe: python - tail stuck under the rocks? Pin
kalberts17-Jul-19 3:12
kalberts17-Jul-19 3:12 
GeneralRe: python - tail stuck under the rocks? Pin
GuyThiebaut13-Jul-19 23:39
professionalGuyThiebaut13-Jul-19 23:39 
GeneralRe: python - tail stuck under the rocks? Pin
Mike Winiberg14-Jul-19 20:55
professionalMike Winiberg14-Jul-19 20:55 
GeneralRe: python - tail stuck under the rocks? Pin
GuyThiebaut14-Jul-19 21:18
professionalGuyThiebaut14-Jul-19 21:18 
GeneralRe: python - tail stuck under the rocks? Pin
Mike Winiberg14-Jul-19 21:27
professionalMike Winiberg14-Jul-19 21:27 
GeneralRe: python - tail stuck under the rocks? Pin
r_hyde13-Jul-19 7:06
r_hyde13-Jul-19 7:06 
GeneralRe: python - tail stuck under the rocks? Pin
Sander Rossel13-Jul-19 9:14
professionalSander Rossel13-Jul-19 9:14 
AnswerRe: python - tail stuck under the rocks? Pin
PIEBALDconsult13-Jul-19 5:07
mvePIEBALDconsult13-Jul-19 5:07 
AnswerRe: python - tail stuck under the rocks? Pin
Sander Rossel13-Jul-19 9:19
professionalSander Rossel13-Jul-19 9:19 
AnswerRe: python - tail stuck under the rocks? Pin
GuyThiebaut13-Jul-19 20:07
professionalGuyThiebaut13-Jul-19 20: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.