Python library to extend functional operations in the spirit of functional programming in scala. Provides support for missing operations and chain style functional calls.
EntilZha on master
Update DNS (compare)
0.4.0
I found an issue where because the wheel distribution depends on the build environment (aka, running on python 2 including enum34 breaking python3 OR running on python3 not including enum34 and breaking python2) I needed to make a hotfix release in 0.4.1
enum-compat
either)
Small suggestions:
__str__
show only part of the sequence, as in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ...]
. Would be even greater if this only evaluated this part, as this would make it usable with infinite generators.*__repr__
show what it really is; maybe <Sequence: [1, 2, 3, 4...]>
or not evaluate at all and show <Sequence wrapping list>
, <Sequence wrapping generator>
, <Sequence wrapping File>
seq.count
as a wrapper for itertools.count
? I'm not sure how far down the "replace seq(thing()) with seq.thing()" path you want to go, that may be an overkill.*(seq(itertools.count())
just killed my computer :P)
__repr__
to do the same thing is for ipython notebook
__str__
and __repr__
could behave differently depending on type of underlying sequence?
Planning on releasing 0.7.0
next week, primary features that will be shipping is the parallel execution engine and file compression support. The main website and docs are now at www.pyfunctional.org and docs.pyfunctional.org respectively (readthedocs can't change scalafunctional.readthedocs.org to pyfunctional.readthedocs.org so this was an easy solution).
The release following this one will most likely be 1.0
, so open to thoughts on what should go in. So far, would like to revamp the readme docs, the webpage at www.pyfunctional.org (currently a clone of the readme), the actual docs, clarify package description, revisit linq, revisit underscore, revisit supporting more than just sqlite, and/or look into adding an option/support to stream things (rather than force open iterables). All this is on top of my head so there could be more
_
operator or pattern matching (that would be really hard to do I think, been looking at existing libraries). Open to suggestions
seq
, but I am working on detecting it as input and doing the correct thing (it gives a list of columns I believe atm but should give a list of rows)
@EntilZha thank you for getting back. The use case I had in mind (which might already be supported by PyFunctional; I haven't tried, but thought of checking with the community first), for example, is I want to write the code below a bit more "functionally."
# `customer` is a Django model, and has a one-to-many relationship with `circuit`
customer_circuits = customer.circuit_set
circuit_ids_that_violate_constraints = []
for circuit_id, new_bandwidth in new_bandwidths.items():
circuit = customer_circuits.get(cid=circuit_id)
if new_bandwidth < circuit.bandwidth_minimum or new_bandwidth > circuit.bandwidth_maximum:
circuit_ids_that_violate_constraints.append(circuit_id)
The code above could be expressed more "functionally" in ruby, for example, along the lines of (just pseudocoding, please don't take it literally):
circuit_ids_that_violate_constraints = circuits
.select({|circuit| new_bandwidth < circuit.bandwidth_minumum})
.select({|circuit| new_bandwidth > circuit.bandwidth_maximum})
.map({|circuit| circuit.cid})
@EntilZha
Do you know this smart_open library?
https://github.com/RaRe-Technologies/smart_open
I think seq.open
can use this library as backend to support S3 or HDFS and remove gzip or bzip2 related codes.
csv.reader
is being used in the seq.csv
so if its not possible to pass the right parameters to that then it might make sense to add another method like seq.csv_dict
etc
csv.DictReader
makes each row a named tuple according to a list of field names or if thats not given then the first row of the csv file. Seems like having another method is good here, question is what to name it.