curiousefficiency.orgCurious Efficiency
curiousefficiency.org Profile
curiousefficiency.org
Sub Domains:python-notes.curiousefficiency.org
Title:Curious Efficiency
Description:Efficiency (a virtue) is the child of laziness and greed (both vices), while
much of our economic activity is devoted to preventing boredom in the idle
time created by increases in efficiency. To be human is to be a strange
creature indeed :)
Discover curiousefficiency.org website stats, rating, details and status online.Use our online tools to find owner and admin contact info. Find out where is server located.Read and write reviews or vote to improve it ranking. Check alliedvsaxis duplicates with related css, domain relations, most used words, social networks references. Go to regular site
curiousefficiency.org Information
Website / Domain: |
curiousefficiency.org |
HomePage size: | 236.152 KB |
Page Load Time: | 0.219188 Seconds |
Website IP Address: |
104.28.5.109 |
Isp Server: |
CloudFlare Inc. |
curiousefficiency.org Ip Information
Ip Country: |
Singapore |
City Name: |
Singapore |
Latitude: |
1.2896699905396 |
Longitude: |
103.85006713867 |
curiousefficiency.org Keywords accounting
curiousefficiency.org Httpheader
Date: Tue, 25 Feb 2020 00:52:11 GMT |
Content-Type: text/html; charset=utf-8 |
Transfer-Encoding: chunked |
Connection: keep-alive |
Set-Cookie: __cfduid=d53f3170f448d166de51dd22854d0ec701582591931; expires=Thu, 26-Mar-20 00:52:11 GMT; path=/; domain=.curiousefficiency.org; HttpOnly; SameSite=Lax |
Last-Modified: Sun, 17 Mar 2019 04:34:23 GMT |
Access-Control-Allow-Origin: * |
Expires: Tue, 25 Feb 2020 01:02:11 GMT |
Cache-Control: max-age=600 |
X-Proxy-Cache: MISS |
X-GitHub-Request-Id: 4292:5D6A:1AC80:1DA7F:5E546FBB |
Via: 1.1 varnish |
Age: 0 |
X-Served-By: cache-sjc10037-SJC |
X-Cache: MISS |
X-Cache-Hits: 0 |
X-Timer: S1582591931.381491,VS0,VE180 |
Vary: Accept-Encoding |
X-Fastly-Request-ID: fec87128bf87ff01732ac2334de80a82bfe9a1cb |
CF-Cache-Status: DYNAMIC |
Server: cloudflare |
CF-RAY: 56a5b1f30f7f9bc7-SJC |
Content-Encoding: gzip |
curiousefficiency.org Meta Info
charset="utf-8"/ |
content="width=device-width, initial-scale=1" name="viewport"/ |
content="#5670d4" name="theme-color"/ |
content="Nikola (getnikola.com)" name="generator"/ |
104.28.5.109 Domains
curiousefficiency.org Similar Website
Domain |
WebSite Title |
curiousefficiency.org | Curious Efficiency |
library.cee1.org | Find the Energy Efficiency Resources You Need | Energy Efficiency Program Library |
wavefunction.fieldofscience.com | The Curious Wavefunction |
15list.com | 15List - Be Curious |
curiousconcept.com | Curious Concept |
mrjam.typepad.com | The Curious Diary of Mr Jam |
app.curiositystream.com | CuriosityStream - Stay curious |
curiositybyjigs.com | Curious Musings – The words and I are up to something |
curiousinventor.com | Home Page - Curious Inventor |
store.curiousinventor.com | Home Page - Curious Inventor |
puzzlebaron.com | Puzzle Baron | Puzzles for Curious Minds |
wnpr.org | Connecticut Public Radio | Media for the curious |
randomhistory.com | FactRetriever Interesting Facts for the Curious Mind |
facts.randomhistory.com | FactRetriever | Interesting Facts for the Curious Mind |
stream.wnpr.org | Connecticut Public Radio | Media for the curious |
curiousefficiency.org Traffic Sources Chart
curiousefficiency.org Alexa Rank History Chart
curiousefficiency.org Html To Plain Text
Skip to main content Toggle navigation About Archives Tags RSS Python Notes What does "x = a + b" mean? Nick Coghlan 2019-03-16 06:06 Comments Making sense of "x = a + b" Shorthand notations and shared context The original shared context: Algebra The corresponding Python context: Numbers Another mathematical context: Matrix algebra The corresponding Python context: NumPy Arrays Python's string concatenation context Python's immutable sequence concatenation context Python's mutable sequence concatenation context A brief digression back to mathematics: Multisets And back to Python once more: collections.Counter What does all this have to do with the idea of dictionary addition? Shorthand notations and shared context Guido van Rossum recently put together an excellent post talking about the value of infix binary operators in making certain kinds of operations easier to reason about correctly. The context inspiring that post is a python-ideas discussion regarding the possibility of adding a shorthand spelling ( x = a + b ) to Python for the operation: x = a.copy() x.update(b) The PEP for that proposal is still in development, so I'm not going to link to it directly [1] , but the paragraph above gives the gist of the idea. Guido's article came in response to the assertion that infix operators don't improve readability, when we have plenty of empirical evidence to show that they do. Where this article comes from is a key point that Guido's article mentions, but doesn't emphasise: that those readability benefits rely heavily on implicitly shared context between the author of an expression and the readers of that expression. Without a previous agreement on the semantics, the only possible general answer to the question "What does x = a + b mean?" is "I need more information to answer that". The original shared context: Algebra If the additional information supplied is "This is an algebraic expression", then x = a + b is expressing a constraint on the permitted values of x , a , and b . Specifying x = a - b as an additional constraint would then further allow the reader to infer that x = a and b = 0 . The corresponding Python context: Numbers The use case for + in Python that most closely corresponds with algebra is using it with numbers - the key differences lie in the meaning of = , rather than the meaning of + . So if the additional information supplied is "This is a Python assignment statement; a and b are both well-behaved finite numbers", then the reader will be able to infer that x will be the sum of the two numbers. Inferring the exact numeric type of x would require yet more information about the types of a and b , as types implementing the numeric + operator are expected to participate in a type coercion protocol that gives both operands a chance to carry out the operation, and only raises TypeError if neither type understands the other. The original algebraic meaning then gets expressed in Python as assert x == a + b , and successful execution of the assignment statement ensures that assertion will pass. In this context, types implementing the + operator are expected to provide all the properties that would be expected of the corresponding mathematical concepts ( a + b == b + a , a + (b + c) == (a + b) + c , etc), subject to the limitations of performing calculations on computers that actually exist. Another mathematical context: Matrix algebra If the given expression used uppercase letters, as in X = A + B , then the additional information supplied may instead be "This is a matrix algebra expression". (It's a notational convention in mathematics that matrices be assigned uppercase letters, while lowercase letters indicate scalar values) For matrices, addition and subtraction are defined as only being valid between matrices of the same size and shape, so if X = A - B were to be supplied as an additional constraint, then the implications would be: X , A and B are all the same size and shape B consists entirely of zeroes X = A The corresponding Python context: NumPy Arrays The numpy.ndarray type, and other types implementing the same API, bring the semantics of matrix algebra to Python programming, similar to the way that the builtin numeric types bring the semantics of scalar algebra. This means that if the additional information supplied is "This is a Python assignment statement; A and B are both matrices of the same size and shape containing well-behaved finite numbers", then the reader will be able to infer that X will be a new matrix of the same shape and size as matrices A and B , with each element in X being the sum of the corresponding elements in A and B . As with scalar algebra, inferring the exact numeric type of the elements of X would require more information about the types of the elements in A and B , the original algebraic meaning gets expressed in Python as assert X == A + B , successful execution of the assignment statement ensures that assertion will pass, and types implementing + in this context are expected to provide the properties that would be expected of a matrix in mathematics. Python's string concatenation context Mathematics doesn't provide a convenient infix notation for concatenating two strings together (aside from writing their names directly next to each other), so programming language designers are forced to choose one. While this does vary across languages, the most common choice is the one that Python uses: the + operator. This is formally a distinct operation from numeric addition, with different semantic expectations, and CPython's C API somewhat coincidentally ended up reflecting that distinction by offering two different ways of implementing + on a type: the tp_number->nb_add and tp_sequence->sq_concat slots. (This distinction is absent at the Python level: only __add__ , __radd__ and __iadd__ are exposed, and they always populate the relevant tp_number slots in CPython) The key semantic difference between algebraic addition and string concatenation is that in algebraic addition, the order of the operands doesn't matter ( a + b == b + a ), while in the string concatenation case, the order of the operands determines which items appear first in the result (e.g. "Hello" + "World" == "HelloWorld" vs "World" + "Hello" == "WorldHello" ). This means that a + b == b + a being true when concatenating strings indicates that either one or both strings are empty, or else the two strings are identical. Another less obvious semantic difference is that strings don't participate in the type coercion protocol that is defined for numbers: if the right hand operand isn't a string (or string subclass) instance, they'll raise TypeError immediately, rather than letting the other operand attempt the operation. Python's immutable sequence concatenation context Python goes further than merely allowing + to be used for string concatenation: it allows it to be used for arbitrary sequence concatenation. For immutable container types like tuple , this closely parallels the way that string concatenation works: a new immutable instance of the same type is created containing references to the same items referenced by the original operands: >>> a = 1, 2, 3 >>> b = 4, 5, 6 >>> x = a + b >>> a (1, 2, 3) >>> b (4, 5, 6) >>> x (1, 2, 3, 4, 5, 6) As for strings, immutable sequences will usually only interact with other instances of the same type (or subclasses), even when the x += b notation is used as an alternative to x = x + b . For example: >>> x = 1, 2, 3 >>> x += [4, 5, 6] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: can only concatenate tuple (not "list") to tuple >>> x += 4, 5, 6 >>> x (1, 2, 3, 4, 5, 6) In addition to str , the tuple , and bytes types implement these concatenation semantics. range and memoryview , while otherwise implementing the Sequence API, don't support concatenation operati...
curiousefficiency.org Whois
"domain_name": [
"CURIOUSEFFICIENCY.ORG",
"curiousefficiency.org"
],
"registrar": "GANDI SAS",
"whois_server": "whois.gandi.net",
"referral_url": null,
"updated_date": [
"2019-07-07 13:39:45",
"2019-07-07 15:39:45"
],
"creation_date": "2011-07-22 02:59:27",
"expiration_date": "2020-07-22 02:59:27",
"name_servers": [
"DAN.NS.CLOUDFLARE.COM",
"LOLA.NS.CLOUDFLARE.COM"
],
"status": [
"clientTransferProhibited https://icann.org/epp#clientTransferProhibited",
"clientTransferProhibited http://www.icann.org/epp#clientTransferProhibited"
],
"emails": [
"abuse@support.gandi.net",
"193bcb17d20506926356c7e54b218a2e-1849554@contact.gandi.net"
],
"dnssec": [
"unsigned",
"Unsigned"
],
"name": "REDACTED FOR PRIVACY",
"org": null,
"address": "63-65 boulevard Massena",
"city": "Paris",
"state": "Paris",
"zipcode": "75013",
"country": "FR"