Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 434 435 [436] 437 438 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 909840 times)

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6525 on: November 06, 2014, 12:20:26 am »

(I gather that Python doesn't support concurrent threads so you must use multiple processes?)

https://docs.python.org/3.2/library/concurrent.futures.html

ThreadPoolExecutor may be what you want there.

There's also the threading module.

Of course, yeah, if you want actual multiprocessing, you're going to need the process stuff.
« Last Edit: November 06, 2014, 12:22:05 am by Putnam »
Logged

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6526 on: November 06, 2014, 12:31:17 am »

Ah, this was the thing that I was thinking of:

Quote
CPython implementation detail: In CPython, due to the Global Interpreter Lock, only one thread can execute Python code at once (even though certain performance-oriented libraries might overcome this limitation). If you want your application to make better use of the computational resources of multi-core machines, you are advised to use multiprocessing or concurrent.futures.ProcessPoolExecutor. However, threading is still an appropriate model if you want to run multiple I/O-bound tasks simultaneously.

So you can't do computation on multiple threads but can overlap it with I/O.  I don't see that mentioned on the concurrent.futures page though, so does it get around that somehow?
Logged
Through pain, I find wisdom.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6527 on: November 06, 2014, 12:39:07 am »

Get around what? I'm kind of confused by your structure >_>

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6528 on: November 06, 2014, 12:51:00 am »

Maybe I'm just misunderstanding, but it looks to me that you can't have multiple threads in the same process performing any calculations.  Threads are only useful if you have a lot of blocking operations (network, disk, whatever), because the process can suspend the threads doing the blocking I/O operation and let another thread that has computation to do run instead.  If you have two threads that only do computation, it looks to me that using threads in a single process gives no benefit in Python since only one can be active at a time.

In my case, I might have a lot of game objects that need to have positions updated, and at the same time I need to update the astronomical simulator.  If the update time starts taking too long then doing the astronomical simulation in a separate thread would be an easy way to offload most of the update time, but based on what I'm reading I won't get any benefit doing that at all since none of that depends on blocking I/O.  I'd need to offload it to a separate process to see any benefit.
Logged
Through pain, I find wisdom.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6529 on: November 06, 2014, 01:14:17 am »

Okay, yes, and Python has the separate ProcessPoolExecutor for that. I haven't used that much, though (the one time I did, it was bad code that ended up taking down the computer I was on with an accidental fork attack whoops), so I'm not sure at exactly how it works.

Thief^

  • Bay Watcher
  • Official crazy person
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6530 on: November 06, 2014, 05:28:51 am »

All told it works out to about 1,000 lines of Python code I think, consisting of tons and tons and tons of trigonometry and linear algebra.  I shudder to think how much C++ code this would have taken.
If you want to find out, post it!
Logged
Dwarven blood types are not A, B, AB, O but Ale, Wine, Beer, Rum, Whisky and so forth.
It's not an embark so much as seven dwarves having a simultaneous strange mood and going off to build an artifact fortress that menaces with spikes of awesome and hanging rings of death.

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6531 on: November 06, 2014, 08:59:16 am »

So my coworker found this somewhere and I thought some of you might like it.

Java! Real or Not?

I'm up to 6/30, but I haven't used Java for years and have never used Spring.
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6532 on: November 06, 2014, 09:03:26 am »

All told it works out to about 1,000 lines of Python code I think, consisting of tons and tons and tons of trigonometry and linear algebra.  I shudder to think how much C++ code this would have taken.
If you want to find out, post it!

Yeah I'd like to try this too. "about the same" would be my guess. If something doesn't work natively in C++ you can often just make a new operator for it that does the job in the same number of lines.

Personally, I think C++ scales better to really complex stuff than quick and dirty scripting languages do. The full blown typing system in C++ allows that - it's that comprehensive for a reason. Python and co are great if you want to prototype something really quick. But if you want a really complex simulation that will be easy to maintain in the long run, go for C++.
« Last Edit: November 06, 2014, 09:08:32 am by Reelya »
Logged

Arx

  • Bay Watcher
  • Iron within, iron without.
    • View Profile
    • Art!
Re: if self.isCoder(): post() #Programming Thread
« Reply #6533 on: November 06, 2014, 09:08:18 am »

So my coworker found this somewhere and I thought some of you might like it.
Java! Real or Not?
I'm up to 6/30, but I haven't used Java for years and have never used Spring.

10/30 so far.

Never even heard of Spring, and don't use Java on the same level as most B12ers. Blind luck for the win!
Logged

I am on Discord as Arx#2415.
Hail to the mind of man! / Fire in the sky
I've been waiting for you / On this day we die.

cerapa

  • Bay Watcher
  • It wont bite....unless you are the sun.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6534 on: November 06, 2014, 09:59:55 am »

edit: Fudged my understanding a bit.

So my coworker found this somewhere and I thought some of you might like it.
Java! Real or Not?
I'm up to 6/30, but I haven't used Java for years and have never used Spring.

10/30 so far.

Never even heard of Spring, and don't use Java on the same level as most B12ers. Blind luck for the win!

There is a 1/3 chance of getting the right one by just randomly picking, which is what you got. I also got that.
Mephisto somehow got 1/5. He did worse than just picking randomly.
« Last Edit: November 06, 2014, 10:04:42 am by cerapa »
Logged

Tick, tick, tick the time goes by,
tick, tick, tick the clock blows up.

Arx

  • Bay Watcher
  • Iron within, iron without.
    • View Profile
    • Art!
Re: if self.isCoder(): post() #Programming Thread
« Reply #6535 on: November 06, 2014, 10:09:12 am »

At one point I was actually getting them right nearly half the time, and for long enough to be non-luck based, but that was mostly based off the fact that their system is slightly gameable.
Logged

I am on Discord as Arx#2415.
Hail to the mind of man! / Fire in the sky
I've been waiting for you / On this day we die.

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6536 on: November 06, 2014, 10:20:08 am »

There is a 1/3 chance of getting the right one by just randomly picking, which is what you got. I also got that.
Mephisto somehow got 1/5. He did worse than just picking randomly.

Because I get crap like this:

Quote
ResourceHandlerRegistration
Context
SpringFailOnTimeoutDeferredResult.DeferredResultHandler.ResultDataAccessExceptionResolver

FYI, 2 and 3 are real.
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #6537 on: November 06, 2014, 10:21:01 am »

Why does anyone even use spring? All its names are dumb :|
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Thief^

  • Bay Watcher
  • Official crazy person
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6538 on: November 06, 2014, 10:44:24 am »

Why does anyone even use spring? All its names are dumb :|
"ConfigClassesAndProfilesWithCustomDefaultsMetaConfig"
Yep.

EDIT: Incidentally I've never used Spring or even heard of it, and I still got 10/15. Spring's names are dumb.
« Last Edit: November 06, 2014, 10:46:23 am by Thief^ »
Logged
Dwarven blood types are not A, B, AB, O but Ale, Wine, Beer, Rum, Whisky and so forth.
It's not an embark so much as seven dwarves having a simultaneous strange mood and going off to build an artifact fortress that menaces with spikes of awesome and hanging rings of death.

Sergius

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6539 on: November 06, 2014, 12:53:29 pm »

This is somewhat related to coding but not really, it's more a hardware/electronics question. Say I wanted to make my own "game cartridge", for a silly project using a Raspberry Pi. All I really want is a plastic box containing a SD card (removable or not), wired to external cartridge-like pins, which in turn plug into a base that in turn connect those pins back into the SD port of the Pi. How would one go around doing that? Is it even remotely feasible?

Do we even have a specialized "electronics" thread? Heh. 8)
Logged
Pages: 1 ... 434 435 [436] 437 438 ... 796