« first day (1642 days earlier)      last day (3300 days later) » 

9:00 AM
@Katherina they're teaching Java 1 instead of Java 8
 
user4433485
I have to develop a android application
 
user4433485
in like 5 weeks
 
@AnttiHaapala in a meeting; need to read all your stuff :)
 
Easy. Do it in Kivy.
 
@Antti although... it might be possible if Martijn completely smashes the initial threshold...
 
9:04 AM
wait, I need to check
that's the problem with STV:
it causes head ache
 
cbg @JRichardSnape
 
If people vote for me as 1st and Jon 2nd he totally is going to be in.
 
of course
 
That's the whole point of STV.
 
9:07 AM
@Martijn I get your sloppy seconds hey :)
When Martijn breaks the rqeuire amount to be elected, all his remaining/surplus gets redistributed to the other choice vote etc...
 
but it would be good if martijn endorsed joncle anw :d
then sopython would have majority in these elections .d
 
And then we have the sopython party? The first step into taking over the world! muhahh muhahha muhahah?
 
Then we form the "Grand Old Python" Party and get into real politics.
 
@Katherina voted yet?
but these elections are so easy
I will just vote for 2 or max 3 candidates in the election who I know would make good mods
not like the parliamentary elections here
where I need to choose from meh candidates to avoid bigger damage (the locally biggest party gaining more seats)
 
9:12 AM
@JonClements You know you have my first!
 
why? :D
 
@AnttiHaapala because you are not running, Jon is.
 
user4433485
@AnttiHaapala no I didn't ! Could you link?
 
@Katherina primaries now you can upvote, downvote all the candidates if you wish
soon then the actual election
 
@Katherina: that teacher of yours should come out to the real world for a while. Show them blog.codeeval.com/codeevalblog/2015#.VS4r1RPF-pc= and tiobe.com/index.php/content/paperinfo/tpci/index.html.
 
9:14 AM
@Martijn I was going to actually vote you first... cos if I wasn't running - I'd do that anyway... (and also, some people not you first under the impression they don't need to or something silly)
 
@MartijnPieters can't trust tiobe, it could be wrong, it's using php
 
user4433485
@AnttiHaapala Thanks, voted up for @MartijnPieters
 
@Katherina thanks. :-)
@Katherina: @JonClements is running to!
 
I'm not actually gonna vote for either of you. We don't need more Python help, Python is already pretty clean. We need a linkedin mod!
 
@Ffisegydd justin kolinar?
 
9:16 AM
 
Damn I should have ran on that ticket "Vote for me and I will purge the entire tag!"
 
26
Q: Could a question asking about a lack of reply from LinkedIn have been salvaged by editing?

Ganesh SittampalamI flagged this question (now deleted) as Very Low Quality because I couldn't see any way it could be fixed by editing: We have applied to LinkedIn API partnership program, its been 20 days, still we doesn't received any reply from them. Any suggestions on the next steps. My flag was ...

 
@Ffisegydd good thing you did not, that'd have been a disaster for me!
 
@Ffisegydd ^lol
 
user4433485
@MartijnPieters Voted up for @JonClements aswel:D
 
9:17 AM
@Ffisegydd can I promise to do that to get your vote, but I reserve the right to completely deny I've stated I would if elected? :p
(that's how politics works isn't it :p)
 
How about this, you promise to do whatever I ask if you're elected, on the understand that I promise never to ask?
 
Okay... then we can both break our promises and not feel bad about it because the other person did the same anyway?
 
lol :D
nokia acquired/merged with alcatel-lucent
which had acquired bell labs
 
user4433485
9:36 AM
anyone here worked with the scrum method?
 
I haven't
 
I used to be a prop forward in school if that counts.
 
the key is that everyone has worked for a company that says it does scrum/agile/whatever
 
user4433485
ah
 
but actually doesn't.
 
user4433485
9:38 AM
I will have to use scrum method from now on
 
user4433485
I don't really get it tho ^^
 
you should read books
 
@Katherina nor do a lot of people that profess to use it in my experience :)
 
You should forget about it entirely for now.
 
I read a stack of 20 books
it made me very bitter
not actually useful at all :D
 
9:39 AM
You're barely learning to program, forget learning about agile and scrum rubbish.
 
@AnttiHaapala and how did you think "comic books" where going to help? :p
 
... what I now know is that I can say "I have read these 20 books and according to each of them what we currently do is wrong"
 
user4433485
@Ffisegydd so true, we only learn documentation stuff
 
user4433485
lol @AnttiHaapala
 
Ummm ValueError: Shape of passed values is (0, 0), indices imply (5, 0)
 
9:41 AM
Seriously, it will do you significantly more harm than good to be messing around with agile/scrum/whatever-the-lastest-fashion is.
Learn to bloody code first.
 
what the hell is happening on the homepage for that to crop up - there isn't even any data access for that!
 
IMHO @Ffisegydd is right - forget the fashion-driven methods until you can code well.
 
scrum is not fashion driven method
 
user4433485
I don't want to use those methods with 24/7 documentation :( But I don't really have a choice.
 
oops
maybe too harsh
 
user4433485
9:43 AM
some students here are struggling with a simple if else in php :)
 
scrum is 20 yrs old, what is fashionable is to lie about scrum
 
I feel they're all pretty fashion driven. My opinion only (and I'm grumpy as only 1 coffee thus far)
Mind you - I think things can be old and fashionable. My haircut attests to that.
:D
 
user4433485
lol;D
 
it is not even about programming
 
user4433485
What is it
 
9:46 AM
it is "the new new product development game" from the era when there even weren't big software products like today
 
user4433485
=D
 
anw it is the only paper that you need to read to understand what scrum is supposed to be about
 
@AnttiHaapala I'm scarred from years in different businesses (allegedly) using Statistical Process Control, six sigma, prince II, waterfall models, test driven development and so on (some software, some not). To be honest, I've never worked anywhere explicitly claiming to do scrum. So, I'll defer to someone with experience
 
@JRichardSnape me neither
the SCP, six sigma etc are ok
 
YNr
Hi, how I can convert a dictionary of lists of numbers to an array?
 
9:51 AM
but they're not about new software product development
 
@AnttiHaapala They would be if people did them is my point
I know they're not software (hence the caveat) - just examples of (in my view) methodologies that it is fashionable to claim to use.
 
they are manyfacturing practices
waterfall model is also misunderstood
 
what the initial waterfall model said was that "use 1/3 budget to do a prototype, then you know how to make the whole product"
 
I know. Days of measuring snychromesh rings for gearboxes with a micrometer taught me that ;)
 
9:53 AM
I'm currently contracting at a subsidiary of Alcatel-Lucent.
 
@MartijnPieters old news
 
With ex-Nokia employees here being teased about how they could run but not hide..
 
@Martijn @Antti mentioned that about an hour ago :)
 
@JonClements ah, but I was trying to work! :-P
 
@MartijnPieters A fatal mistake ;)
 
9:54 AM
excuses - excuses ;)
 
but so funny, Bell Labs will report to Espoo :d
too bad the chairman of the board is not very clever, but at least the CEO is
 
@AnttiHaapala This company does Agile big time.
which is why I am suffering right now..
 
Anyhow - I should get off my grumpy tangent about various methodologies, software, manufacturing or otherwise). I think we violently agree - probably all have some good foundational ideas, nearly all are mis-interpreted / mis-applied by most who claim to use them (not all, I know)
 
release plan, so working out stories for all epics slated for the release, tentatively assigned to the team I am in.
1 week of meetings..
@JRichardSnape There are always issues, niggles, etc. but this is the closest I've ever been to a pure Agile environment.
 
argh - mismatched paranthesis. I really must need coffee ☕
@MartijnPieters It is interesting when you work in a place that does adhere almost purely to a given proceess / methodology. Only happened to me once and it was one they'd rolled themselves.
It did lead to quicker and less ambiguous communication between team members, I would say
 
9:58 AM
The normal 2-week cycle I love; it's a great framework for large-scale engineering.
I'm not that great at continued meetings, a real energy drain.
We do do the work around the wall by our desks, in meeting rooms, have a lot of fun with it, but still.
 
Yup - I'll agree with that on the cycle. I don't mind meetings myself - but can see it can be draining
 
meetings are waste of time
 
user4433485
@AnttiHaapala You live in Finland right? what cars are they actually driving in Scandinavia? I can imagine that Fiat is a terrible choice with the cold of the north =D
 
@Antti if they're organised and held properly - they can be productive... otherwise - I despise meetings because someone wants a meeting about what to meet about
 
<wanders off to a meeting to plan world domination*>
*get more coffee
rbrb
 
10:09 AM
world domination is far more fun if you just adhoc it :)
 
Well, all kinds of cars yes, but of course with indoor heating and winter tyres in winter etc. I do not own a car myself, a bicycle is cheaper and usually faster; even if 1 would be stolen annually, it is still less than just the parking fees for a car :P
my uncle swore in the name of Fiat :D
though in Finland Fiat would not be considered a good brand anw,
mostly occurring jokes about there being a merger between Fiat and Skoda and the new brand being called Fiasko
@Katherina ^
 
Meagar has surpassed bluefeet's vote tally from last year, I see.
 
@Martijn yup... much more voting this year which is quite good - be interesting to see the total stats broken down and compare them to last year
 
Skoda are good now though
Though they must rank as one of the weirder brands to keep alive
 
Yay. Reached 80,000 :-)
 
10:24 AM
Also, I like the idea of scrum, especially where you can change requirements as you go, but the downside is that if you're the person paying, you need to have a lot of trust in the team
 
@RobertGrant yeah, this is actually what has sucked with "scrum" in the organizations that I have been in:
"these are the playing pieces we're given, now play with them"
 
"Here's a straw... an empty cereal box and some glue.... we need to build a theme park..."
 
more about the ppl
it is always like "we have 3 programmers in our company, so you 3 are a scrum team"
or
 
Which is axiomatically incorrect; scrum team is SM, PO and at least 3 developers
 
we have 6 people in the company, 3 of them actually can do anything at all
 
10:26 AM
cbg @khajvah
 
but since scrum team needs to have more than 3 then we have all these 6 in the "team"
 
The absolute best thing about it, which I want to try and introduce here, is Product Owner.
That is brilliant.
 
@JonClements Hi :)
 
@Ffisegydd if you've got a moment later - might have to pick your brain re: pandas
(although.... I might have solved it...)
 
10:42 AM
def f(word):
vowels = {"a", "e", "i", "o", "u"}
other_letters = {"w","y"}
if vowels+other_letters in word:
return(True)

is there a way to do this? where any of the vowels and any of the 2 other letters can be used. E.g. if "ay" or "ew" are in the word
ugh sorry, i thought i pressed crtl + k
 
Push uparrow a couple of times, maybe it'll still be available. Yes, it will.
Or is that Slack? Nope.
 
@Roger Are you checking if all the characters are there in word?
 
nope, I wanna check if any are
 
any single vowel / other letters or combinations of a vowel and other.... I'm not quite following
 
Any vowel and any other letter. So "ay", "ey", "iy"... "aw", "ew", "iw"...
 
10:49 AM
Is it me or is the SO voting page really, really terrible?
 
@Roger what about wa, we etc...?
 
(@Robert Grant it's you. You're terrible.) - Yes, I know
 
nah, only the other way around
 
Not sure why you're using sets...
 
cbg
 
10:50 AM
letter in vowel + letter in other_letters
I thought using sets would be a good idea
 
Let's talk about them, baby
 
@Roger First, take a look at itertools.product.
 
@AnttiHaapala I...hmm.
 
@Roger not reallly build up combos in the order you're looking for eg: combos = [a + b for a in 'aeiou' for b in 'wy']
Then something like return any(combo in word for combo in combos)
 
No. First way. Man I love Jon Clements
 
10:52 AM
Actually, this might be better done using a regex.
 
Yeah I was wondering regex
 
Sure.... return re.match('|'.join(combos), word)
 
return re.match('[aeiou][wy]')
 
maybe wrap it in bool or end it with is not None
 
pat=re.compile("[aeiou][wy]")
match = pat.search(word)
 
10:54 AM
if [a + b for a in 'aeiou' for b in 'wy'] in word:
is pretty much what I want, but the correct syntax for it?
 
That's better :)
I juts have a horrible feeling I've seen this before for an assignment and the criteria was "you're not allowed to use regex"
 
Well if it's for an assignment, then regex is the way to go in giving the answer :)
 
Yeah.... I saw this as a Q a couple of days again
 
nah it's not an assignment question at all, and I don't know what regex is :P
 
they were after iterating over it char by char... checking if a set of letters was proceeded by another set of letters
 
@Roger Lucky you! Seriously, regex is short for Regular Expression, a very powerful tool for finding patterns in strings. See docs.python.org/3/library/re.html for the Python way of doing regexes.
 
cbg @jonrsharpe
 
cbg all!
 
How goes your day?
 
@AnttiHaapala regarding that delete view_config, and just so I understand things a bit better, does what you've written give someone with the delete permission the power to delete everything?
@jonrsharpe I also voted against the hilarious screenshot of code edit that someone made to that post
 
11:00 AM
@RobertGrant I voted for it - it's the OP's fault the post is terrible, the edit at least made that clearer!
 
Hah true
Maybe I should edit in PLEASE VOTE TO CLOSE THIS QUESTION.
 
@JonClements good thanks, it's a lovely sunny day here in Berkshire (I can see out of the office window...)
 
Regular Expressions are a mini-language in their own right. Although they can be very powerful it's very easy to create regexes that are hard to read. It takes a while and a lot of practice to get good at writing regexes, and even more practice to be able to read regexes created by others. :)
 
I got 99 problems, and regular expressions comprise the majority
 
@RobertGrant I think you mean r'\d{2}' problems...
 
11:02 AM
Some people love using regexes in every possible situation, even when simple string searching & replacement can do the job more efficiently. And some string processing tasks are really not well-handled by regex, the classic case being the parsing of arbitrary HTML or XML.
 
@RobertGrant yes, but it would work with the object permissions, right
the ACL would look at the ACL for the Company object in question
 
@Robert I rejected as "no improvement whatsoever" - it fits under that category
 
the point in that is that the same code would work for deleting Users, or Apples
 
adding an image of code doesn't help... and it's only a couple of capitalisations made to the text
 
@PM2Ring That may be a symptom of coming from another languages where regexes are the only way to do any major string processing
 
11:05 AM
@RobertGrant also, zope.interface allows giving interfaces to objects (not just classes), so you could say "this very object now conforms to this interface (while the other objects of its class does not)"
otoh I hate it when ppl do not use regexes for a case where it would be shortest
 
@JonClements I rejected as custom: Fuzzy screenshots of code considered harmful
 
@TheBlackCat Funny you should say that. About a week ago, someone asked here why so many Python programmers hate regex. I replied that we don't hate regex, just over-use of regex. But I conceded that there may be some prejudice against regex due to them being such a major thing for Perl programers, and there's a bit of a tradition of Perl - Python rivalry / animosity.
 
@AnttiHaapala yeah I mean if I have 10 models, someone with that delete permission will be able to delete all ten of them?
(I think the answer's no, from what you said earlier, but just to check)
 
yes, and no, if given the delete permission to all 10 then ofc one can delete all 10.
that was just an example
the point was the genericity; you can really do ducktyping and what not :D
 
I'm trying to interpret your code snippet correctly: would that as it is allow the user to delete all the SQLA models?
 
11:10 AM
In the toolbox of Python programming I think regex is the bradawl - it might look like a screwdriver, and will work as one in a pinch, but is best saved for the specific task it's good at. And you certainly shouldn't use it where a hammer is needed.
@JonClements it's now hung 2:2, I'm on tenterhooks
 
Bah... were I mod etc... etc... :p
Let's see who's voted to approve it
Why'd you approve that? Makes puppy want to cry....
 
read it in context :D
invalid
 
@JonClements as above; the edit does at least move towards the author's intention (even if that intention is ridiculous - a literal photograph of a screen?!)
 
"This edit does not make the post even a little bit easier to read, easier to find, more accurate or more accessible. Changes are either completely superfluous or actively harm readability."
 
@JonClements yeah, fair point
It did capitalise some is, though!
 
11:18 AM
And they only capitalised two is, deleted a full stop - there's other issues that could have been made to the text (which was actually text)... :)
Well, they broke it into paragraphs, but they could at least have bothered to fix: but the second part is what im having difficulties.
 
@Roger Here's a non-regex way of doing it. You _could _ make semivowels a set, but there's not much point.
def has_vowels_and_semi(word):
    vowels = 'aeiou'
    semivowels = 'wy'
    rc = False
    for v in vowels:
        i = word.find(v)
        if i != -1 and i < len(word) - 1:
            rc |= word[i+1] in semivowels
    return rc

words = ['bay', 'dawn', 'help', 'one', 'tower']

for word in words:
    print word, has_vowels_and_semi(word)
 
Looks like the question is going to get deleted, but stackoverflow.com/review/suggested-edits/7694984
 
bay True
dawn True
help False
one False
tower True
 
Lol someone else approved it
@PM2Ring blurgh
 
Sorry, minor C&P error. Then I accidentally hit Enter...
 
11:25 AM
still rejectable
 
user4433485
@AnttiHaapala haha =D I just saw your message, made me laugh :p
 
@AnttiHaapala ahh... you got the last reject in - cool :p
 
`if i != -1 and i < len(word) - 1:`
could be better written as
`if -1 < i < len(word) - 1:`
 
Lunchtime - rbrb all
 
11:31 AM
rbrb
 
Antti Haapala has approved 778 edit suggestions and rejected 1 edit suggestions wtf?
what's that 1 there?
 
A bug.
 
surely
 
That's a lot of approving :)
 
11:36 AM
43
Q: Suggested edits showing the wrong stats

gunr2171Yesterday I made a post about putting a reviewer's stats when the "improve" or "reject and edit". That post is about including the information. This post is about the information shown being '0' or being wrong. I did some more reviewing of suggested edits and found this: This is obviously wro...

 
upvote pls ^
 
I believe they now display the correct stats for me
 
Well, okay. Because it's you.
 
vaultah has approved 493 edit suggestions and rejected 196 edit suggestions
 
Antti Haapala has approved 778 edit suggestions and rejected 1 edit suggestions
Dhaval Bhadania has approved 673 edit suggestions and rejected 47 edit suggestions
Jon Clements has approved 771 edit suggestions and rejected 465 edit suggestions
Robert Grant has approved 31 edit suggestions and rejected 6 edit suggestions
jonrsharpe has approved 422 edit suggestions and rejected 19 edit suggestions
surely not right since I have gold badge from the editq
 
11:42 AM
Jan 24 at 19:54, by Jon Clements
Mind you - the ratio for approved/rejected looks a bit one sided: vaultah has approved 377 edit suggestions and rejected 1 edit suggestions
 
soz, I was away @PM2Ring and thanks so much again. Bye all
 
@Roger No worries. I've got a slightly better version, if you like.
 
Martijn Pieters has approved 628 edit suggestions and rejected 608 edit suggestions
 
def has_vowels_and_semi(word):
    for v in 'aeiou':
        i = word.find(v)
        if -1 < i < len(word) - 1:
            if word[i+1] in 'wy':
                return True
    return False
 
11:59 AM
cabage all
 
{32: 33.0, 75: 1600.0, 62: 2526.0}
{'8': 75, '43': 62, '16': 32}

i want some thing like this

{'8':1600.0,'16':33.0,'43':2526.0}
i got error some create my new dict
 
Is this one of those aptitude tests?
 
not a aptitiue
 
I would be interested in seeing the error, and seeing the code that caused the error.
 
12:05 PM
my own code
k
 
@DaSaDiYaChaiTAnYa That sounds very defensive :)
 
Hey everyone, I have a newbie question. Is there quick one-liner to check if a float x exists in a tuple (a, b)? Right now I'm using a, b = interval and a <= x <= b, but I don't like this solution. x in interval is wrong, since this only checks if x is one of the endpoints. Googling didn't bring up any obvious answers to this.
 
new_dict2[k]=res[k]
KeyError: '16'
this error comes from my side
i will post my question again with proper syntext
 
@void-pointer nothing wrong with that - it's clear what you're doing
 
hmm, I got your desired output looking at the docs and trying out a comprehensive list
 
12:10 PM
res={32: 33.0, 75: 1600.0, 62: 2526.0}
new_dict2={'8': 75, '43': 62, '16': 32}

i want some thing like this
new updated dictionary
new_dict2={'8':1600.0,'16':33.0,'43':2526.0}
and i got my error some think like this
new_dict2[k]=res[k]
KeyError: '16'
 
@JonClements Ok, thanks for the confirmation.
 
@void-pointer "one-liners" are over-rated stuffs, really
 
@JonClements please help to resolve this error
 
what matters is readability, clearity and understandability
 
oh wow, I'm surprised my code worked even though the keys were different in data types
 
12:12 PM
@PeterVaro Yes!
 
as Jon claimed, what you are doing is perfectly fine
 
Yeah, but I'm now forced to write an auxiliary function just to use a list comprehension.
 
cbd all (cbd on purpose, those who know will know)
 
cbg(@InbarRose)
 
cbg @InbarRose
 
12:13 PM
@DaSaDiYaChaiTAnYa it's unclear as to what you're doing - you're not explaining that - just posting more code - that's not helping you or anyone... Also - it's not considered polite to ping people directly asking for help... there's already people looking and commenting on your messages... try responding to their comments if you want help...
 
cbg
 
@JonClements i just want to update my new_dict2 dictionary nothing else
 
cbg @AvinashRaj :)
@DaSaDiYaChaiTAnYa and what exactly are the steps you'd like to achieve that? You have a dict of strs->ints, and a dict of ints->ints... I don't see what your "update rules" are... you need to explain that...
 
@DaSaDiYaChaiTAnYa When I said I wanted to see the code that caused the error, I meant the entire source code, not just the one line where the exception occurred. Sorry for the confusion.
 
okey kiven and jon clements
 
12:19 PM
@void-pointer I might be stating the obvious here, but you could do it in one line with interval[0] <= x <= interval[1].
 
oh, nvm, the keys I used to get the second values were of the right type :) OK back to work
 
@Kevin Yeah, I was hoping for some kind of function that could cast a float pair into a continuous range. I guess that doesn't exist.
 
@Kevin you could, but you'll find unpacking faster then __getitem__ look ups
 
@void-pointer not really. It's not too difficult to make your own "float_range" function, but of course it would still be discrete.
 
@DaSaDiYaChaiTAnYa I think this is what you want. Note, this is Python 2.6 code. It could be improved slightly in Python 3
res = {32: 33.0, 75: 1600.0, 62: 2526.0}
new_dict2 = {'8': 75, '43': 62, '16': 32}
new_dict2 = dict((k, res[v]) for k, v in new_dict2.items())
print new_dict2
Output: {'8': 1600.0, '43': 2526.0, '16': 33.0}
 
12:24 PM
pair = (1.0, 99.99)
%timeit a, b = pair
%timeit pair[0], pair[1]
10000000 loops, best of 3: 50.1 ns per loop
10000000 loops, best of 3: 136 ns per loop
 
I guess you could also create your own Interval class, which overrides in such that x in Interval(23,42) does what you want, but we're in overkill territory here
@JonClements I am mildly surprised!
 
cabbage everybody and others
 
cbg @Xavier
 
@Kevin I'm not. Unpacking a tuple is very efficient. As you can see it's more efficient than doing index arithmetic & dereferencing.
 
Cabbage to everybody, and everybody that is not part of everybody. I have a headache.
@PM2Ring I guess I'm spoiled by C++, where array indexing is embarrassingly fast.
 
12:28 PM
@PM2Ring its python 2.7 code over hear
 
@PM2Ring Cool, I had almost the same thing, good to learn that [ ... ] was not really needed
 
Fair enough. But even in C/C++ doing stuff with pointers can be even faster than mucking around with array indices. OTOH, modern compilers can often optimize that stuff, eg by lifting constant calculations out of loops, and invisibly converting array manipulations to using pointers.
 
Not sure what you mean, at the machine level, there's no distinction between arrays and pointers.
 
Well, I mean, array indexing is literally just item_address = beginning_of_array_address + (index * size_of_an_item). It's hard to get any more efficient than one mult and one add.
 
Yes, but "doing stuff with pointers can be even faster than mucking around with array indices" doesn't make much sense.
 
12:34 PM
Or are you saying that you don't even need the mult and add if the compiler notices that you're using a constant as an index during compilation time? I'll agree with that.
 
@Jerry With the [...] it's a list comprehension (list comp). Without, it's a generator expression (gen exp). So instead of building a list of tuples & passing it to dict(), we pass an iterator that creates tuples, and dict() consumes them as they're produced. A gen exp can be a little slower than a list comp, but it requires less memory. However, in some cases a list comp is better than a gen exp, eg when using the str.join() method.
 
@Jerry thanks a lot it resolve successfully
 
@PM2Ring oh cool
 
I went with c = {key: a[value] for key, value in b.iteritems()} for the dict thing, myself
 
@Kevin I mean that manipulating pointers is equivalent to manipulating array indices. Also, compilers will typically use instructions like "lea" to load from an offset past a given address, so it's only one instruction.
 
12:36 PM
@Jerry it's different syntax; you are doing something different. It's not like the [] are optional. Difference explained by pm above.
 
@void-pointer, OK, I think we're on the same page, then :-)
 
Cabbage
 
@Jerry good to see your code ideone.com/r3jjLL good helpful for me
 
@MartijnPieters Wonder what happened to that sentence when I first posted that post… thanks
 
If I compile the Python code using something like Cython, can I expect these operations to be inlined away in a compiled language like C++?
*inlined away as they would be in a compiled language like C++
 
12:41 PM
I've never used Cython, but my gut says "no"
 
@void-pointer if you can, you should use the Python/C API instead
 
@void-pointer depends what you're trying to do... if it's your example, then no... you've already got it sorted
 
indexing objects in Python can have all sorts of side-effects, as defined by the class' __getitem__ method, so it would be tricky to optimize that away.
 
Cython is a nice tool, but even for me it is very hard to follow which will be turned into what
 
@void-pointer Sure, but doing arithmetic on a pointer & then dereferencing it is more efficient than doing arithmetic on an index and then subscripting an array with that index. But as I said, modern compilers will handle such optimizations for you.
 
12:43 PM
anyway, if you are compiling "untouched" python to Cython then indexing won't be "inlined"
 
Ok, thanks for the information. I have a lot of experience with C++ and just started to learn Python, so it's interesting to see that simple operations that I would normally expect the compiler to optimize away can carry a lot of overhead in Python.
 
yes, because python is still a dynamic and interpreted language
while C and C++ are static and compiled languages
don't try to act and think like you were in those low levels
and free yourself and start developing at the nice, dynamic, higher levels of python ;)
 
@void-pointer That's a major downside of the dynamic nature of Python - it makes it very hard for the interpreter to do many optimizations that would be elementary in a compiled language.
 
(ofc if you understand the underlying structure of how python is working, you could write better code in python itself)
 
Yeah, static typing gives the compiler many extra optimization opportunities. I use Python mostly for quick numerical experiments and graphing.
 
12:47 PM
@PM2Ring or you can think of it as a massive upside :)
 
C++ is evolving towards more Pythonic syntax as well. I wouldn't really put modern C++ at the same level as C.
 
numerical analysis it's not so good... but for a lot of applications, it's more than worth the flexibility
 
If I need performance I go back to C++ =P
 
@void-pointer although even in C++14 most of the sugars are zero-cost-abstractions
so in some sense, it is at the same level as C
 
@JonClements :) I think the upsides of a dynamic duck-typed language far outweigh the downsides.
 
12:49 PM
wb @Antti
 
I need "project identification":D
 
@PeterVaro Yup, I just meant that the concepts I use to think with when typing modern C++ are closer to those of Python than those of C, at least most of the time.
 
@void-pointer anyway, what I would suggest: write the performance-intense parts in C/C++ and wrap them with teh Python/C API and use them from Python -- but only after you measured everything and you still need those optimisations
 
And I guess the downside of "magic" optimization is that you don't really know what your program's doing once the compiler's done re-arranging it.
 
@void-pointer :P
 
12:50 PM
@PeterVaro Yeah, there's also Boost.Python which I'd like to explore.
 
I've never used that..
 
OTOH, lack of automatic optimization tempts people to do premature optimization on their code, and as Knuth said premature optimization is the root of all evil.
 
Think I tried to use that once in 2004 for something... I bet it's come a long way in 11 years though
 
@JonClements oh, you think so? ;)
 
12:51 PM
I'd kinda hope so
 
using the right algorithm is not premature optimization :D
 
My fear is that it hasn't been updated in a while. One of the main authors (David Abrahams) joined Apple and works on Swift now. Not sure how well-maintained it is now.
 
I wonder if there's any black-magic way to make print statements actually use pprint in Python 2 (without using the print_function future)...
 
'All the current Boost.Python test cases passed' well, that's more than I expected
 
@ThiefMaster even catering for something like print >> f, a, b, c like stuff or just stdout?
 
12:53 PM
i just care about simple print statements - would be a bit nicer for debug prints
 
@ThiefMaster Wrap it in function with ever shorter name, like log?
 
that's not the point :p
the only thing i could imagine is using an import hook that actually rewrites the imported code to use pprint instead of print... but it's probably not worth the time
 
umm... I'm struggling... because I'm not sure it's convenient to get the original arguments to the statement.... it's easy to get the result of it, but that's not the point
 
@ThiefMaster convert your code to print_function using 2to3
 
So yeah... short of transforming the ast or something... I'm coming up blank for the mo'
 
12:58 PM
then you can replace __builtins__.print
 
@AnttiHaapala Certainly: I didn't mean to imply that using the right algorithm is premature optimization. OTOH, many times people re-invent the wheel & don't realize that an efficient algorithm already exists and is well-researched.
 
>>> from __future__ import print_function
>>> from pprint import pprint as print
>>> print(globals())
{'__builtins__': <module '__builtin__' (built-in)>,
 '__doc__': None,
 '__name__': '__main__',
 '__package__': None,
 'print': <function pprint at 0x0000000001E38B38>,
 'print_function': _Feature((2, 6, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 65536)}
 

« first day (1642 days earlier)      last day (3300 days later) »