« first day (2339 days earlier)      last day (1105 days later) » 

07:51
:D
@LuisMendo (-: and I imagine in spanish you have to write an initial upside-down smiley :-)
0
Q: Is bsxfun still optimal in MATLAB?

JangI did bump into this question while searching for this topic, but this one seems to be outdated. Reading https://blogs.mathworks.com/loren/2016/10/24/matlab-arithmetic-expands-in-r2016b , an implicit expansion was introduced years ago, but I can still find the reference codes in the papers using ...

where's Divakar when you need him :P
@Adriaan after a bit of pythoning I must admit, I don't miss bsxfun
but it was fun having an function with such an obscure name
@flawr I barely ever used bsxfun myself I must admit. But I'm a shoddy programmer anyway
08:17
@Adriaan neither did I, except to mess with other people who either didn't really know bsxfun or were not so sure about the whole linalg rules anyway:)
 
4 hours later…
12:29
Note also that implicit expansion seems to do some (unexpected) optimizations that bsxfun does not do — Luis Mendo 41 mins ago
Thanks for digging that up @LuisMendo ! I didn't even remember asking that :P
 
1 hour later…
13:40
@Adriaan :-D I remember it well because it's such a weird behaviour, and I don't feel very comfortable with it:
What's the next stage in this optimization? x = ones(1e200, 1e300); clear x running in no time? — Luis Mendo Sep 16 '19 at 17:52
13:59
@LuisMendo I think it makes a lot of sense. The JIT gets to look at each statement as a single unit, intermediate steps are not required to be created or stored. Why wouldn’t it do that?
Reading @Adriaan’s answer there and following links, I eventually found this comment of mine: blogs.mathworks.com/loren/?p=149#reply_23269
Not saying that they implemented implicit singleton expansion because of me, I’m sure they had thought of it themselves by then.
@CrisLuengo that's similar to Python's garbage collection, no? That scans the file and finds the last use of a variable and then throws it out after that
@Adriaan garbage collection is deleting memory blocks that are no longer referenced by any variables. If Python does as you describe, which would be quite clever, it wouldn’t be called garbage collection, I don’t think.
What I referred to is converting an expression such as a+b+c form a loop that computes tmp=a+b and then another that computes tmp+c into a single loop that does both computations at the same time, never creating the intermediate matrix tmp.
There is a trick in C++ that can do this too, for custom operators that work on objects. Matrix libraries like Eigen do this. Way too complicated for me to attempt to implement…
15:03
@CrisLuengo no. What python does is reference counting. When no more references remain to an object, it gets destroyed practically immediately. But this is not considered garbage collection in python. GC is a special machinery that finds reference cycles: a refers to b, b refers to a, but nobody refers to them. The gc can find these cycles and destroy them. It's more expensive and executes more rarely than deallocation due to refcounting.
cc @Adriaan
"Finding the last use" of a name would amount to solving the halting problem
15:41
Anyone got a dupe for stackoverflow.com/q/70113273/5211833 ? I feel a bit silly about having answered...
@AndrasDeak That is consistent with what I said (or intended to say), but with more detail. In Python GC needs to find cycles in objects that are not referenced by a variable because reference counting cannot identify those.
@Adriaan OP just deleted their question. I hate it when they do that just after receiving an answer. .
Or did you delete your answer first?
@AndrasDeak is that really true? Maybe for global variables it is, but local variables? My IDE points out variable assignments that are pointless because the variable is not used after that point, or overwritten before it’s read again.
@CrisLuengo I deleted first
I already downvoted and should've closed as a dupe. But as usual, answering was quicker than finding the dupe >.<
15:57
@CrisLuengo Because then you cannot be sure that the interpreter is doing what you tell it to. My x = ones(1e200, 1e300); clear x is an example of that. Should the interpreter not run the first part because of the second?
@CrisLuengo Heh, you were many years ahead :-)
@AnderBiguri Huh?
That comment you got, that code-translation is off-topic for Stack Overflow, was incorrect. Undeleting this. — Cody Gray ♦ 30 mins ago
@CrisLuengo Note that the OP's C code uses int16, not uint16...
@LuisMendo Thanks! Will edit.
@LuisMendo If the interpreter can figure out that calling ones has no side effects, then there is no point in calling it. This is easier for a compiler to do than for an interpreter, though.
@LuisMendo oh
well, I always closed this questions of pls give me codez
16:14
@CrisLuengo *waves hand*
you can probably do it in some limited cases, but I would bet you can't do it in a general way
53
A: Is "How do I convert code from this language to this language" too broad?

MakotoYes. Translating code between languages isn't something you can ask of volunteers. My opinion is a bit more forceful in that their understanding of the languages is irrelevant; if they're asking blatantly that they want code in language A to be in language B, they're asking in the wrong place on...

Maybe that changed since 2015. But "please translate the code" is a bad question, off-topic or not
so does it match the exceptions?
Ah, the exceptions. Let's see
It matches the first, possibly the second. Not the others
Anyway, Cody wants it open ¯\_(ツ)_/¯
if I see the timeline correctly it was never closed, he just undeleted it
Ah, yes, sorry. I meant he wants it undeleted
So now let's close it :-P
16:42
@CrisLuengo Huh I have not considered that, I always assumed it was really just as simple as counting references
so actually it seems like it must do some kind of analysis of the whole reference-graph?
@flawr it is, there are two mechanisms :P
@AndrasDeak counting twice? :D
I really should read a little bit more about it
17:03
@LuisMendo I think there is a difference between “translate my program” and “how do I do these bit operators in MATLAB?”
@flawr you can start by rereading what I said first ;)
@Cris Yes, I guess the question is borderline (and your answer is very good anyway)
there's some information about the garbage collector at docs.python.org/3/library/gc.html, exposing some functionality
@LuisMendo Thanks! I answers because there is a way to do it in MATLAB that is different from how you’d do it in other languages. I thought that was interesting to write down.
@CrisLuengo The main problem is, the way it is phrased the OP seems to have no idea what the C code is doing
17:06
Yeah, that is true. It’s a shitty question.
@CrisLuengo Yes, in fact I was going to post a comment pointing the OP to typecast, but then they deleted the question
And Cody totally rewrote it. Did you see the original formulation?
Ah, I didn't notice it had been rewritten
@flawr Don't you find it annoying that (a, b) in maths can denote a Cartesian pair and and open interval? I'm writing stuff that uses both types of objects. Is there any convention to distinguish them (like maybe increased spacing after the comma for intervals)? I couldn't find any, at least in LaTeX Q&A's
Amount of white space having syntactic meaning? That sounds like a bug waiting to happen.
Have you heard of the language “whitespace”? en.m.wikipedia.org/wiki/Whitespace_(programming_language)
@LuisMendo I think it is usually clear from the context, but I'm not aware of any special notation, other than the french notation: ]a, b] = {x :a < x <= b} or [a, b] = {x: a <=x <= b} and ]a,b[ = {x: a< x < b}
17:15
I learned the “French notation” in high school in Spain.
yeah I think it is quite common in europe
Yeah, it's ugly but unambiguous
@CrisLuengo Ah, you mean]a, b[? So did I, but it seems to be non-standard internationally
@flawr Thanks, I saw Cris' comment first :-)
@LuisMendo I wouldn't mind using it, if you fear it doesn't get understood nothing prevents you from just writing a short sentence about the notation used.
@LuisMendo It can also denote a scalar product:)
Problem is, after so many years of not using it myself, I find it weird :-)
17:18
or the gcd
Oh my :-D
(I learned <a,b> for scalar product)
@LuisMendo that must have been the bad influence of physicists
@AndrasDeak I can't break with the tradition of not reading your stuff first :)
I do really feel guilty
@flawr to see how literal reference counting is:
>>> import ctypes
>>> lst = [42]
>>> refcount = ctypes.c_longlong.from_address(id(lst))
>>> refcount.value -= 2
>>> lst
[42]
>>> Segmentation fault
(segfault after exiting the REPL)
@AndrasDeak whoa! Why would the reference count be writable from within Python code?
It's ctypes, so it's not really python code. It hacks CPython.
17:31
@AndrasDeak nice, thanks!
I haven't managed to cause a segfault via python yet
I know shorter
You should post it then!
ah, not anymore
I think it was fixed with a new parser
You can (should) always post stating to which version it applies
17:37
>>> eval('()' * 1000000)
Segmentation fault
it still works, I just didn't go high enough
It works in TIO too tio.run/#Python3
yeah, tio is 3.7, I'm on 3.9
999999 is 1 byte shorter :P
Also remove two spaces
@LuisMendo LOL! “Python is the language of choice for portably crashing your programs.”
2
17:41
:-D
@AndrasDeak obvs 2? eval('()'*9**6)
right
you should check TIO if non-CPython interpreters crash too; probably not
PyPy (whatever that means) doesn't
Poor TIO. I'll stop torturing it
pypy is the largest non-CPython python interpreter, written in python
it has JIT built into it
unfortunately it's a lot behind in development, and probably missing features too
A Python interpreter written in Python...
that's why its logo is a ouroboros
 
2 hours later…
19:21
@LuisMendo C compilers have always been written in C.
ALWAYS?!
The very first one was compiled manually!
In computer science, bootstrapping is the technique for producing a self-compiling compiler — that is, a compiler (or assembler) written in the source programming language that it intends to compile. An initial core version of the compiler (the bootstrap compiler) is generated in a different language (which could be assembly language); successive expanded versions of the compiler are developed using this minimal subset of the language. The problem of compiling a self-compiling compiler has been called the chicken-or-egg problem in compiler design, and bootstrapping is a solution to this problem...
The first C compiler, according to lore, was hand-compiled to assembly, but it could also have been written in B, I don’t know.
they should've written it in python
I have a general question about questions. I want to find a guide to coding a web app that displays photos in flask-python.. It's not a specific, but general question. Is that allowed?
A specific* question about questions
This post has contradictory stories about the first C compiler: softwareengineering.stackexchange.com/questions/76627/…
@mmont questions that ask for external resources (such as a guide) are expressly out of scope for Stack Overflow.
19:36
@CrisLuengo Gotcha. Is there a separate forum that allows such questions?
probably not anywhere on the Stack Exhange network
you could try something less rule-oriented, like a python discord
@CrisLuengo The expresson "write in C" always reminds me of the famous Beatles' song
Nov 11 '19 at 17:58, by Luis Mendo
@AndrasDeak Write in c, write in C, write in C, write in C / Java's not the answer / Write in C
After 2 years I still don't get it :'D
19:53
@LuisMendo It’s a beautiful song, but I’m over C, never going back to it. I do agree with the sentiment about Java though! :D
oh, then that reference is way too far from the original
20:23
@AndrasDeak I think I've actually seen C compilers written in python:)

« first day (2339 days earlier)      last day (1105 days later) »