|
QuarkJets posted:Basically I was going to say what Foxfire_ said; for loops in Python are slow and usually aren't what you want to use for bulk-computation. VBA is a compiled language, but Python is not. Pandas indexing is insanely slow compared to the underlying arrays Also vectorize your poo poo Or don't and use numba its a tossup as to which ends up faster
|
# ¿ Mar 31, 2017 11:59 |
|
|
# ¿ May 4, 2024 05:53 |
|
This has little to do with python being compiled or not: pandas has a ton of overhead if you don't do things the correct way
|
# ¿ Mar 31, 2017 12:00 |
|
Foxfire_ posted:Huh, I was expecting the pandas overhead to be much smaller. Some testing shows that it goes: It is entirety possible to JIT compile python using techniques similar to JavaScript -- hidden classes, partial evaluation, polymorphic inline caching-- but there's a lot more money behind Js dev Pypy does a lot of good things but is a research project first . Maybe graal will help , jruby augmented with truffle and graal is insanely fast comparatively
|
# ¿ Apr 1, 2017 14:49 |
|
oliveoil posted:Is there anything like the JVM spec but for Python? LMAO its whatever Guido fever dreams up and shits out in Cpython Hell it took a heroic effort to get ruby specified and that had people who cared behind it Spelunk through the source. Cpython uses a ref counting mechanic fwiw
|
# ¿ Apr 1, 2017 20:50 |
|
Fwiw attrs is a better namedtuple at the cost of needing a dependency
|
# ¿ Apr 16, 2017 22:38 |
|
shrike82 posted:Sorry, I meant that it's so trivial in Python that people don't tend to think "Oh, I need to use a DI/IoC framework here". The main use I see of IOC containers is magically getting constructor args on creation by registering classes and interfaces which is v unpythonic Otherwise just pass them in as arguments
|
# ¿ Apr 21, 2017 01:37 |
|
Thermopyle posted:This is a nice library that I use fairly often. backoff. oh nice i use retrying but this looks to be more configurable at runtime
|
# ¿ May 15, 2017 23:09 |
|
huhu posted:
Import pathlib Or just use '/' since windows can normalize it just fine (except for the leading r'\\')
|
# ¿ May 17, 2017 22:07 |
|
fluent python owns
|
# ¿ Jun 7, 2017 20:38 |
|
LochNessMonster posted:Never knew floating points behave like this, learning something knew everyday. Did u think that 64 bits was enough to represent all of the reals?
|
# ¿ Jun 10, 2017 12:26 |
|
Boris Galerkin posted:It's more of a hardware limitation than an actual thing. In real life 0.3 is exactly 0.3, but we lose some accuracy when we represent it in a computer. Look at this scrub who doesn't compensate for floating pt errors and is agnostic to precision. Mixed precision iterative refinement
|
# ¿ Jun 10, 2017 12:28 |
|
Next y'all will be like "use doubles" or maybe even "use quads" and then come back like "my prog is mega slow"
|
# ¿ Jun 10, 2017 12:31 |
|
QuarkJets posted:That has nothing to do with floating point errors though; exact Decimal types exist without having to represent all of the reals but the point is that no finite representation can represent real numbers w/o some loss and imprecision, fixed point decimal does it differently than IEEE-754 arbitrary precision is a different game but still limited by practicality
|
# ¿ Jun 11, 2017 01:46 |
|
Cingulate posted:Python is a language that's being used by people with very little CS knowledge (e.g., me). That's, from what I can tell, by design: Python is easy to learn, easy to read, welcoming and forgiving. I think the thread has a good track record of being exactly like that, too. Nippashish posted:That's why I'm suggesting a very simple mental model that is intuitive and also sufficient for even non-beginners. Teaching people that floating point numbers are dark and spooky and complicated isn't very productive, because very few people need to care about that level of detail. Actually this is the worst possible takeaway because Numerical analysis is a) hard and b) for even most practical purposes requires an understanding of when it'll fail on you. Catastrophic cancellation and loss of precision can lead to cases where your component will fail and fail hard. Unless you don't want to engineer robustly, sure you can ignore it. I have run into many cases where poor or no understanding of float approximations have lead to pernicious bugs in production systems costing lots of money While I don't expect people to understand IEEE-754 the standard in its entirety, it is immensely unhelpful to present it as a real number/exact fraction abstraction since it's leakier than a sieve (but designed in such a way to be useful for those in the know) and frequently beginners will smash their heads against the wall for days until they are told how the semantics of floats work when they run into "random" "non-deterministic" errors that are 100% deterministic. For example, addition is commutative but not associative. This isn't trivial nor particularly expected. funny Star Wars parody posted:I'm assuming that you should use doubles but please expand on this True A way of salami slicing Perfectly fine if your algorithms are insensitive to things like that (i use floats in quant finance optimization models) but try simulating a chaotic system and watch as floats are completely useless It gets better when you have no idea how chaotic your system is!
|
# ¿ Jun 11, 2017 21:50 |
|
LochNessMonster posted:As the root cause of this discussion as well as a beginner in terms of programming I can tell you that you're over simplifying things. Floats are 100% deterministic. They will do 100% of what you tell them to do, but that's a pretty complex operation involving rescales and possibly higher precision intermediaries. If you are calculating mathematical functions, use a library or look up a numerically stable algorithm.
|
# ¿ Jun 11, 2017 21:52 |
|
SurgicalOntologist posted:Umm I simulate chaotic systems... what should I be using if not floats? a complicated algorithm that compensates for the fact that the system is very sensitive to accumulated approximation error and a lot of whiskey when b/c even then long term behavior is sketchy Nippashish posted:I'd actually go further and say that it's not just beginners, but most programmers. If you need to worry about the details of floating point numbers then you are doing something quite unusual. any programmer that's using floats for numerical work needs to know when and how they work so when they gently caress up they aren't surprised. math.fsum is in the standard library for a reason Better to learn this now than with actual repercussions on the line QuarkJets posted:This is the level of worrying that Nippashish said a newbie shouldn't be at, and he was 100% right. "Why is this single line of floating-point arithmetic giving me a funny-looking answer" requires a very basic understanding of the issue, not "read this essay on the difficult subject of numerical analysis" Newbies shouldn't worry about how to use lathes, just have them lose a finger or break a few thousand parts instead of having them learn how to use their tools
|
# ¿ Jun 11, 2017 22:34 |
|
QuarkJets posted:Is writing bad analogies required for numerical analysis, now? well it keeps me in a job, so pragmatically no but yes you should understand your tools before you use them, maybe read the fine manual as well Cingulate posted:I would think the entire neural network community largely ignores floating point issues, what with them running near-exclusively on single precision. They have run the analysis and it doesn't matter to them. OP poster was running into self admitted errors and had no idea what was going on, because they had no idea what they were doing. quote:
it's not as fun
|
# ¿ Jun 12, 2017 00:53 |
|
Nippashish posted:
You're wrong and should feel wrong. If you're advocating writing scientific software or numerical software without understanding what's going on, please let me know what you make so I can never use it Not everyone programs fart apps exclusively so its worth knowing when you can and when you can't ignore abstractions OP go read http://floating-point-gui.de/basic/
|
# ¿ Jun 12, 2017 01:02 |
|
SurgicalOntologist posted:Do you have an actual algorithm in mind? Because if so I'd be curious to read up on it. I always figured that after solver issues (i.e. discretization error, stiffness, etc.) and measurement error on initial conditions, floating-point arithmetic is pretty low on the list of concerns. I guess in the sense that getting long term quantitative predictions using floating point is useless due to the accumulated error being magnified. It was a bit glib I have heard good things about differential quadrature methods but can't vouch personally
|
# ¿ Jun 13, 2017 19:43 |
|
Cingulate posted:I generally don't do this, but- if your fun is being needlessly mean towards other people, here's some life advice for you: try doing that less. Try changing. You'll become a happier person, and contribute more to the lives of those around you. Yes I'm going to take life advice from posting on the something awful comedy forums (I think it's pretty clear that every post is tongue firmly jammed in cheek) People who tell learners to ignore things that they barely understand never fails to amuse
|
# ¿ Jun 13, 2017 20:17 |
|
Thermopyle posted:Async basically only helps with IO-bound tasks. If you are mostly CPU-bound you should probably use multiprocessing. Python is like the worst tool for this any code I have that's deeply improved by threading I've shifted over to elixir wince BEAM was designed right and can communicate with python processes for the numpy stuff I wish asyncio was more like erlang
|
# ¿ Jun 15, 2017 15:47 |
|
Lol use an actual diffeq solving codes instead of doing it by hand unless you are researching solvers
|
# ¿ Jun 17, 2017 18:37 |
|
Like instead of the janky first order stuff you could probably use the standard rk4 and be algorithmically faster
|
# ¿ Jun 17, 2017 18:38 |
|
breaks posted:Use the task scheduler unless you have a good reason not to. Running it in a loop will work until your computer reboots or it throws an exception and whatever series of other problems, then by the time you find and fix all those all you get for the extra work and inconvenience is probably a worse task scheduler. Good news: python has one built in: import sched
|
# ¿ Jun 18, 2017 15:39 |
|
Try looking for a computational geometry algorithm that matches what you're trying to do
|
# ¿ Jun 20, 2017 19:54 |
|
Boris Galerkin posted:Ok cool thanks for the info. I figured it was a spec related thing but I guess this is the first time I've ever used a thing where nan or dividing by zero doesn't crash your program. Behold the quiet nan
|
# ¿ Jul 4, 2017 20:03 |
|
Thermopyle posted:Functional programming in python can be done effectively and sometimes it can be done appropriately, but generally you shouldn't go "ok I'm going to write this program functionally". its more of a backwards thing: guido is stuck in the late 80s-90s when it comes to programming ergonomics and thus will never see any benefit in functional programming and the sycophants who make up cPython will thus never do it The upshot is that functional programming in python is far more painful than it needs to be and so you shouldn't use it, making it more painful since no developer will optimize for it, and...
|
# ¿ Oct 27, 2017 15:24 |
|
Boris Galerkin posted:Is there such thing as "statically compiling" an executable Python script? I would like to be able to just distribute the script as an executable with dependencies baked into it so that I don't need to worry about sourcing or creating a venv and whatnot. Yeah py2exe or pex
|
# ¿ Apr 3, 2018 11:53 |
|
The julia diffeq library is insanely good Julia is like a Matlab successor but better
|
# ¿ May 2, 2018 11:18 |
|
Airflow is the worst out there except for everything else Luigi doesn't do scheduling just sequencing Iirc Godspeed goon.
|
# ¿ Dec 19, 2018 18:53 |
|
mr_package posted:I'm parsing a file line-by-line, modifying some of them based on regex pattern matching. Basic pattern is this; forgive the $ variables, trying to simplify so consider this pseudocode/Python hybrid: Use sed
|
# ¿ Jan 24, 2019 02:56 |
|
Yeah I'm glad the python community is realizing that Guido made some bad choices regarding the stdlib and keeping cpython a slow mess
|
# ¿ May 18, 2019 21:41 |
|
Lmao at Guido taking it persomally when someone with expertise makes constructive criticism about his baby and he storms out
|
# ¿ May 18, 2019 21:42 |
|
Thermopyle posted:Yes, people should just rip off the python 2 bandaid. Easier said than done. Would be a lot easier if Guido had engineered (lol) a proper migration strategy instead of winging it and complaining when people dont spend millions upgrading.
|
# ¿ May 18, 2019 23:44 |
|
It's like if pipenv wasn't written by an rear end in a top hat, so yes
|
# ¿ Jun 3, 2019 16:48 |
|
Just be a pre merge hook or ci
|
# ¿ Jul 21, 2019 03:59 |
|
Dominoes posted:Hey dudes. Would anyone be willing to help test if Python binaries I built work on similar systems? Looking for someone with a Ubuntu or Debian install to try this, and specify a Python version you don't have, >= 3.4. Looking for someone with Windows who doesn't have Python 3.7 installed to try it with Python 3.7 specified. Much appreciated. Install a vm and do it yourself dude
|
# ¿ Sep 10, 2019 02:57 |
|
Dominoes posted:I don't get along well with Docker, and am looking for help on an open-source project. You might even be interested in using this later, if not now. What I'm specifically asking for help on is a proof-of-concept for getting official binaries hosted on python.org. https://developer.microsoft.com/en-us/windows/downloads/virtual-machines free 60 day vms (just keep rebuilding it) No docker needed. But a trivial dockerfile for this would be worth it since all you do is setup and d/l. And with microsoft's free CI/CD it'd run automatically which is a lot more reliable than asking idiot goons like myself to test
|
# ¿ Sep 10, 2019 05:04 |
|
Fluue posted:What's the typical pattern for loading credentials from something like AWS SSM Parameter Store into an API wrapper while keeping class initialization lightweight? Is it typically The iron rule of dependency injection strongly suggests you do the latter. Your API wrapper should have no idea where it gets its keys.
|
# ¿ Sep 10, 2019 05:07 |
|
|
# ¿ May 4, 2024 05:53 |
|
Fluue posted:Right. I'm asking whether it's better to init an instance of the API wrapper in the module itself or init the wrapper elsewhere (E.g. when it's needed). The latter, again. For lambdas and scripts I ve always had a driver function that gets all of the config from wherever and then initializes the modules that do the work
|
# ¿ Sep 10, 2019 18:15 |