Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

Krankenstyle posted:

hrmm

i have a list of dicts where a certain key contains a list. i want a merged list of all those lists, but my list comprehension comprehension is lacking... halp?

code:
>>> columns = [{'a': [1,2,3]}, {'a': [4,5,6]}]
>>> [c['a'] for c in columns]
[[1, 2, 3], [4, 5, 6]]
>>> [t for t in c['a'] for c in columns]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'c' is not defined
e: doy

code:
>>> [t for c in columns for t in c['a']]
[1, 2, 3, 4, 5, 6]

you can also use chain, it's somewhat more convenient in some situations... probably not in this one though

code:
from itertools import chain

chain.from_iterable(d['a'] for d in columns)

Adbot
ADBOT LOVES YOU

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



oh neat, I'll keep it in mind. thx!

cinci zoo sniper
Mar 15, 2013




the fast solution to that, just fyi, is an .expand() for loop

Zlodo
Nov 25, 2006

Fatty Crabcakes posted:

4) brief description, ISSUE-42069

This. It's super useful when a super long time later you modify some code and it does something puzzling that you need to remove or modify and you can look up the jira that this was fixing and verify that your changes are not making the bug reappear

we have a perforce commit plugin where we can reference the bug we're fixing so it automatically gets closed and cross referenced with the changelist number, it's super useful

Xarn
Jun 26, 2015

Zlodo posted:

This. It's super useful when a super long time later you modify some code and it does something puzzling that you need to remove or modify and you can look up the jira that this was fixing and verify that your changes are not making the bug reappear

That's what the tests are for? :confused:

I agree with auto linking between commit message body and an issue tracker being useful though.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



cinci zoo sniper posted:

the fast solution to that, just fyi, is an .expand() for loop

you mean .extend()?

Aramoro
Jun 1, 2012




Are there any alternatives to SonarQube that are remotely good?

cinci zoo sniper
Mar 15, 2013




Krankenstyle posted:

you mean .extend()?

yeah

Zlodo posted:

This. It's super useful when a super long time later you modify some code and it does something puzzling that you need to remove or modify and you can look up the jira that this was fixing and verify that your changes are not making the bug reappear

we have a perforce commit plugin where we can reference the bug we're fixing so it automatically gets closed and cross referenced with the changelist number, it's super useful

i thought this went without saying regardless. mine usually here are “Does a thing. Resolves FOO-69.”

Corla Plankun
May 8, 2007

improve the lives of everyone
if you're commiting a list comprehension that is more complicated than something like
code:
[butt>0 for butt in butts] 
I strongly recommend that you rewrite it as a for loop

if you don't, you're gonna be real mad at yourself later for being so clever

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Corla Plankun posted:

if you're commiting a list comprehension that is more complicated than something like
code:
[butt>0 for butt in butts] 
I strongly recommend that you rewrite it as a for loop

if you don't, you're gonna be real mad at yourself later for being so clever

my team is loving awful at this and i have to constantly remind them that "pythonic" means readable and comprehensible not code golf

Zlodo
Nov 25, 2006

Xarn posted:

That's what the tests are for? :confused:
We do little to no automated testing unfortunately. And what we do is very high level testing, things like automatically running AIs in the various racing events of our game and see if they get stuck.

Our qa team have a smoke test procedure to test the major features of the game every time they get a new build, but it's easy to break something that no one will notice - the combinatorial complexity of our features and game flows and game states and the data that it all feeds from is just too much to cover everything.

Some unit testing might help, but the humongous code base was absolutely not designed with unit testing in mind. And then there's the fact that most of our bugs are caused not by individual modules but by the interactions between multiple modules and what the player have in their save and what designers have setup in the data.

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

Corla Plankun posted:

if you're commiting a list comprehension that is more complicated than something like
code:
[butt>0 for butt in butts] 
I strongly recommend that you rewrite it as a for loop

if you don't, you're gonna be real mad at yourself later for being so clever

my rule of thumb is if it's something very rote and dumb then I write whatever muscle memory brings me

if it's likely to be extended with say a lot more business logic eventually then it should be a for-loop for sure

so what cinci zoo sniper said about using extend is a good call for the second case

code:
merged_list = []
for d in columns:
    merged_list.extend(d['a'])

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Zlodo posted:

We do little to no automated testing unfortunately. And what we do is very high level testing, things like automatically running AIs in the various racing events of our game and see if they get stuck.

Our qa team have a smoke test procedure to test the major features of the game every time they get a new build, but it's easy to break something that no one will notice - the combinatorial complexity of our features and game flows and game states and the data that it all feeds from is just too much to cover everything.

Some unit testing might help, but the humongous code base was absolutely not designed with unit testing in mind. And then there's the fact that most of our bugs are caused not by individual modules but by the interactions between multiple modules and what the player have in their save and what designers have setup in the data.

well, that sounds like a nightmare

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
btw I'm surprised python never introduced a special flatten syntax for stuff like that. maybe something that looked a lot like unpacking.

I guess it's one of those python committee arbitrary choices, like having sum() but not product()

Zlodo
Nov 25, 2006

DONT THREAD ON ME posted:

well, that sounds like a nightmare

It's not as bad as I make it sound, we take our time, take the time to analyze the technical feasability of new features, do extensive code reviews and build a ton of in-game debugging tools to help us troubleshoot problems

but our biggest force is that we have lot of experienced people who are able to correctly anticipate development costs, so we rarely end up having to rush things

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


what the gently caress why does this method pass an instance of a class to itself as a parameter for its own save method :psyduck:

Ellie Crabcakes
Feb 1, 2008

Stop emailing my boyfriend Gay Crungus

Because you touch yourself at night.

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Fatty Crabcakes posted:

Because you touch yourself at night.

do not expose my private methods tyvm


bonus: all the methods on the class are set to internal because.....no wait there's no reason at all.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Powerful Two-Hander posted:

what the gently caress why does this method pass an instance of a class to itself as a parameter for its own save method :psyduck:

that’s upsetting

Achmed Jones
Oct 16, 2004



Powerful Two-Hander posted:

what the gently caress why does this method pass an instance of a class to itself as a parameter for its own save method :psyduck:

oh so there’s this rule of software development that also holds true for devops, sre, security engineering, and occasionally life. the fundamental law is: because gently caress you, that’s why

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Powerful Two-Hander posted:

what the gently caress why does this method pass an instance of a class to itself as a parameter for its own save method :psyduck:

if i had to guess someone probably wrote a dal abstraction layer that uses the class type as an entity to pass into a factory that saves the right object type but then forgot what they were doing and gently caress you that's why

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Blinkz0rz posted:

if i had to guess someone probably wrote a dal abstraction layer that uses the class type as an entity to pass into a factory that saves the right object type but then forgot what they were doing and gently caress you that's why

you're giving the devs involved far too much credit here.

i think it's some stupidity involving changing the execution path from "iterate over a list saving each object (regardless of whether it had actually changed) " to "save an individual object when that object is explicitly changed" and rather than, you know, refractor anything to be vaguely logical they just took away the iteration without bothering to change its methods.

even then though I can't quite figure out what the gently caress was going on before... an object that has a list of itself as a property and also has a method that saves an individual instance of itself or something hosed up like that.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang




weird that list comprehensions are slower than for-loops. youd think theyd be at least the same speed

cinci zoo sniper
Mar 15, 2013




Krankenstyle posted:

weird that list comprehensions are slower than for-loops. youd think theyd be at least the same speed

i meant to say that this is definitely faster than itertools.chain, though i wouldn’t be surprised if in general case extend still is the fastest - im not familiar with its implementation

gonadic io
Feb 16, 2011

>>=

Krankenstyle posted:

weird that list comprehensions are slower than for-loops. youd think theyd be at least the same speed

It's because lol interpreted langs. Does adding comments inside a loop still slow it down?

galenanorth
May 19, 2016

I'm running the last CSV-creating program, for all the Fifth Third Bank branch locations and ATMs, before I register as an official business. It's got 3 days to go until it finishes running because the FCC's API for adding county data given lat-long data is slow and I've been putting off learning to do client-side GIS with Python

In the meanwhile I'm getting started on scraping data from Kroger, a grocery store chain which has its data available as a JSON object buried in the HTML source code of its store locator page. After I list my business on Google Ads for a month, if it doesn't bring in enough money, I'll get a full-time job and switch to working on the project on weekends. My parents have been sick and my mom is getting colon surgery soon. The project is the only reason I haven't gotten a job yet, but I can always quit the job if I need to in order to take care of my mom when she gets back from surgery.

galenanorth fucked around with this message at 19:21 on Feb 18, 2019

Private Speech
Mar 30, 2011

I HAVE EVEN MORE WORTHLESS BEANIE BABIES IN MY COLLECTION THAN I HAVE WORTHLESS POSTS IN THE BEANIE BABY THREAD YET I STILL HAVE THE TEMERITY TO CRITICIZE OTHERS' COLLECTIONS

IF YOU SEE ME TALKING ABOUT BEANIE BABIES, PLEASE TELL ME TO

EAT. SHIT.


Blinkz0rz posted:

dal abstraction layer

a dalal if you will

Sapozhnik
Jan 2, 2005

Nap Ghost
Lol python

Remember that time Guido got up in someone's face during that guy's presentation about how their company tried to optimize some hot paths in cpython so it wasn't quite so poo poo slow

Ellie Crabcakes
Feb 1, 2008

Stop emailing my boyfriend Gay Crungus

Achmed Jones posted:

oh so there’s this rule of software development that also holds true for devops, sre, security engineering, and occasionally life. the fundamental law is: because gently caress you, that’s why
:hmmyes:

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Private Speech posted:

a dalal if you will

:thejoke:

Private Speech
Mar 30, 2011

I HAVE EVEN MORE WORTHLESS BEANIE BABIES IN MY COLLECTION THAN I HAVE WORTHLESS POSTS IN THE BEANIE BABY THREAD YET I STILL HAVE THE TEMERITY TO CRITICIZE OTHERS' COLLECTIONS

IF YOU SEE ME TALKING ABOUT BEANIE BABIES, PLEASE TELL ME TO

EAT. SHIT.



id like to say 'i know'

but really my eyes glazed over halfway through that post

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



cinci zoo sniper posted:

i meant to say that this is definitely faster than itertools.chain, though i wouldn’t be surprised if in general case extend still is the fastest - im not familiar with its implementation

oh, right. turns out list comps are actually faster than for loops anyway lol

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison

galenanorth posted:

I'm running the last CSV-creating program, for all the Fifth Third Bank branch locations and ATMs, before I register as an official business. It's got 3 days to go until it finishes running because the FCC's API for adding county data given lat-long data is slow and I've been putting off learning to do client-side GIS with Python

In the meanwhile I'm getting started on scraping data from Kroger, a grocery store chain which has its data available as a JSON object buried in the HTML source code of its store locator page. After I list my business on Google Ads for a month, if it doesn't bring in enough money, I'll get a full-time job and switch to working on the project on weekends. My parents have been sick and my mom is getting colon surgery soon. The project is the only reason I haven't gotten a job yet, but I can always quit the job if I need to in order to take care of my mom when she gets back from surgery.

how’s the weather in kentucky

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

cinci zoo sniper posted:

i meant to say that this is definitely faster than itertools.chain, though i wouldn’t be surprised if in general case extend still is the fastest - im not familiar with its implementation

is it? I mean, it is if you're converting the iterable to a list sure but... well, if you're working with lists you shouldn't be worrying about speed really tbh

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
lol at the very idea of having to care about iterator performance in a plang

perhaps if performance mattered to you you should choose a language with zero cost abstractions, like rust :smug:

cinci zoo sniper
Mar 15, 2013




Symbolic Butt posted:

is it? I mean, it is if you're converting the iterable to a list sure but... well, if you're working with lists you shouldn't be worrying about speed really tbh

about twice faster iirc. i sometimes have this problem at the scale of 10^7 lists, where that is an appreciable improvement

gonadic io
Feb 16, 2011

>>=

DONT THREAD ON ME posted:

lol at the very idea of having to care about iterator performance in a plang

perhaps if performance mattered to you you should choose a language with zero cost abstractions, like rust :smug:

i'm interviewing at a company that claims to be doing HFT ...in f#

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

gonadic io posted:

i'm interviewing at a company that claims to be doing HFT ...in f#

yeah that sounds difficult. i havent used f# but one of the most difficult parts of scala for me was reasoning about memory performance. what's going on in memory is really not exposed via the language. i guess you can say this for any managed language but scala is functional and complicated.


coming back to a managed langs after working on unmanaged is weird.

DONT THREAD ON ME fucked around with this message at 23:26 on Feb 18, 2019

redleader
Aug 18, 2005

Engage according to operational parameters
.net is pushing towards giving devs finer-grained control over allocations for perf-sensitive applications - e.g. with Span<T> being a stack-allocated type, things like ref structs

Adbot
ADBOT LOVES YOU

gonadic io
Feb 16, 2011

>>=

DONT THREAD ON ME posted:

coming back to a managed langs after working on unmanaged is weird.

honestly the biggest issue i have is that rust has "match foo {" and scala has "foo match {"

well that and my hobby laptop is a surface book and work is a mac so the \" and the @ keep swapping places, also backslash

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply